马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#------将文件分段保存-----#
boy = []
girl = []
count = 1
f = open('C:/Users/asus/Desktop/record.txt')
for each_line in f:
(role, line_spoken) = each_line.split(':', 1)
if role == '小甲鱼':
boy.append(line_spoken)
if role == '小客服':
girl.append(line_spoken)
else:
if each_line[:6] == '======':
boy_file_name = 'boy' + str(count) + '.txt'
girl_file_name = 'girl' + str(count) + '.txt'
boy_file = open(boy_file_name)
girl_file = open(girl_file_name)
boy_file.writelines(boy)
girl_file.writelines(girl)
boy_file.close
girl_file.close
boy = []
girl = []
count += 1
程序运行之后出现:
(role, line_spoken) = each_line.split(':', 1)
ValueError: not enough values to unpack (expected 2, got 1)
求问各位大佬这是怎么回事?
|