029一个任务,运行程序没有反应
f = open('D:\\桌面\\record.txt','r')count = 1
boy = []
girl = []
for each_line in f:
if each_line[:3] != '===':
(role,spoken) = each_line.split(':',1)
if role == '小甲鱼':
boy.append(spoken)
if role == '小客服':
girl.append(spoken)
else:
f1 = 'boy_'+str(count)+'.txt'
f2 = 'girl'+str(count)+'.txt'
boy_file = open(f1,'w')
girl_file = open(f2,'w')
boy_file.writelines(boy)
girl_file.writelines(girl)
boy_file.close()
girl_file.close()
boy = []
girl = []
count += 1
f.close() f = open('record.txt')
要你的.py程序与record.txt文件位于同一个目录才行 突然找到生成的文件了 f = open('record.txt') 我这样写为什么会找不到文件,而小甲鱼却可以?
页:
[1]