|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
f=open('D:\\专业课\\总\\test1.txt')
me=[]
xiao=[]
count=1
for each_line in f:
if each_line[:6]!='======':
(role,line_spoken) = each_line.split(':',1)
if role=="我":
me.append(line_spoken)
if role=="小甲鱼":
xiao.append(line_spoken)
else:
file_name_me='me_'+str(count)+".txt"
file_name_xiao='xiao_'+str(count)+".txt"
me_file=open(file_name_me,'w')
xiao_file=open(file_name_xiao,'w')
me_file.writelines(me)
xiao_file.writelines(xiao)
me_file.close()
xiao_file.close()
me=[]
xiao=[]
count+=1
f.close()
|
|