|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
import pickle
count=1
dialog1=['oj']
dialog2=['bk']
boy_file_name='小甲鱼_1.txt'
girl_file_name='小客服_1.txt'
tell=open('record.txt')
for each_line in tell:
if each_line[:6]!= '======':
if each_line.split(':')[0]=='小甲鱼':
dialog1.append(each_line.split(':')[1])
if each_line.split(':')[0]=='小客服':
dialog2.append(each_line.split(':')[1])
else:
f=open(boy_file_name,'wb')
m=open(girl_file_name,'wb')
pickle.dump(dialog1,boy_file_name)
pickle.dump(dialog2,girl_file_name)
f.close()
m.close()
count+=1
boy_file_name='boy_'+str(count)+'.txt'
girl_file_name='girl_'+str(count)+'.txt'
dialog1=[]
dialog2=[]
tell.close()
Traceback (most recent call last):
File "C:\Users\86187\Desktop\dialog.py", line 20, in <module>
pickle.dump(dialog1,boy_file_name)
TypeError: file must have a 'write' attribute
|
|