|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
在看小甲鱼视频,在零基础学习python中有问题不太懂,就是run时报错,但还是出现了四个文档
npy = open('D:\\玩具1号.txt')
zb = []
gz = []
count = 1
for each_line in npy:
if each_line[: 6] != '======':
(role,line_spoken) = each_line.split(':',1)
if role == '主播':
zb.append(line_spoken)
if role =='观众':
gz.append(line_spoken)
else:
file_name_zb = 'zb_' + str(count)+'.txt'
file_name_gz = 'gz_' + str(count)+'.txt'
zb_file = open( file_name_zb,'w')
gz_file = open( file_name_gz,'w')
zb_file.writelines(zb)
gz_file.writelines(gz)
zb_file.close()
gz_file.close()
zb = []
gz = []
count += 1
npy.close()
|
|