|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
如题,请问29课的示例中
没有设置路径,那么文件将保存在哪里?- f=open('E://record.txt')
- boy=[]
- girl=[]
- count=1
- def file_save(boy,girl,count):
- file_name_girl='girl'+str(count)+'.txt'
- file_name_boy='boy'+str(count)+'.txt'
- file_girl=open(file_name_boy,'w')
- file_boy=open(file_name_girl,'w')
- file_girl.writelines(girl)
- file_boy.writelines(boy)
- file_girl.close()
- file_boy.close()
- for each_line in f:
- if each_line[:6] != '======':
- [role,spoken_line]=each_line.split(':',1)
- if role=='小客服':
- girl.append(spoken_line)
- if role=='小甲鱼':
- boy.append(spoken_line)
- else:
- file_save(boy,girl,count)
- count+=1
- file_save(boy,girl,count)
复制代码
|
|