|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
f=open('E:\\recored.txt',encoding='utf8')
boy=[]
gril=[]
count=1
for each_file in f:
if each_file[:6] != '=====':
(role,spoken)=each_file.split(':',1)
if role=='小甲鱼':
boy.append(spoken)
if role=='小客服':
gril.append(spoken)
else:
file_name_boy='boy_'+str(count)+'.txt'
file_naem_gril='gril_'+str(count)+'.txt'
boy_file=open(file_name_boy,'w')
gril_file=open(file_naem_gril,'w')
boy_file.writelines(boy)
boy_file.writelines(gril)
boy_file.close()
gril_file.close()
boy=[]
gril=[]
count+=1
f.close()
Traceback (most recent call last):
File "E:/txt.py", line 9, in <module>
(role,spoken)=each_file.split(':',1)
ValueError: not enough values to unpack (expected 2, got 1)
小客服:小甲鱼,今天有客户问你有没有女朋友
这里的冒号是中文的,程序中是英文的,不一致。
|
|