|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
问题描述:在“文件:一个任务”那一章中,按照小甲鱼的视频下载了小甲鱼与小客服的对话的文本(我自己保存为了123.txt),但是做完之后的应该有的boy1.txt,girl1.txt等文本不知道在哪去了,我的Python安装目录是‘D:\\python.37’,但是这里面找不到刚刚的作业结果,我把我的代码、目录截图发过来:
作业代码:
f = open('D:\\python3.7\\123.txt')
boy = []
girl = []
count = 1
for i in f:
if i[:6] != '======':
(a,b) = i.split(':',1)
if a == '小甲鱼':
boy.append(b)
if a == '小客服':
girl.append(b)
else:
file_name_boy = 'boy' + str(count) +'.txt'
file_name_girl = 'girl' + str(count) + '.txt'
file_boy = open(file_name_boy,'w')
file_girl = open(file_name_girl,'w')
file_boy.writelines(boy)
file_girl.writelines(girl)
boy = []
girl = []
count += 1
file_name_boy = 'boy' + str(count) +'.txt'
file_name_girl = 'girl' + str(count) + '.txt'
file_boy = open(file_name_boy,'w')
file_girl = open(file_name_girl,'w')
file_boy.writelines(boy)
file_girl.writelines(girl)
file_boy.close()
file_girl.close()
f.close()
按下F5后运行后的没有显示错误,我的Python路径在图片中可以看到,请问有谁知道我作业的那6个文本保存在哪个位置了吗?搜索不到也
|
|