试一下修改冒号
将英文版冒号修改为中文版冒号
import pickle
def save_file():
boy_file = open('boy_',str(count),'.txt','wb')
girl_file = open('girl_',str(count),'.txt','wb')
pickle.dump(boy,boy_file.pkl)
pickle.dump(girl,girl_file.pkl)
boy_file.close()
girl_file.close()
def split_file(file_name):
f = open(file_name)
boy = []
girl = []
count = 1
for each_line in f:
if each_line[:2] == '===':
save_file(boy,girl,count)
boy = []
girl = []
count += 1
else:
(name,content) = each_line.split(':',1)
if name == '小甲鱼':
boy.append(content)
if name == '小客服':
girl.append(content)
save_file(boy,girl,count)
f.close()
split_file('record.txt')
|