马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
def save_files():
boy_file_name = 'boy_' + str(count) + '.txt'
girl_file_name = 'girl_' + str(count) + '.txt'
boy_file = open(boy_file_name, 'w')
girl_file = open(girl_file_name, 'w')
boy_file.writelines(boy)
girl_file.writelines(girl)
boy_file.close()
girl_file.close()
def file_split(file_name):
f = open('record.txt')
boy = []
girl = []
count = 1
for each_lines in f:
if each_lines[:2] != '==':
(role, words) = each_lines.split(':', 1)
if role == '小甲鱼':
boy.append(words)
if role == '小客服':
girl.append(words)
else:
save_files()
boy = []
girl = []
count += 1
save_files()
f.close()
file_split('record.txt')
为啥这样会输出boy_3.txt和girl_3.txt??
|