-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcon_split.py
More file actions
30 lines (26 loc) · 906 Bytes
/
con_split.py
File metadata and controls
30 lines (26 loc) · 906 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
def save_(role1,role2,count):
file1='倚天屠龙记\\赵敏_'+str(count)+'.txt'
file2='倚天屠龙记\\张无忌_'+str(count)+'.txt'
with open(file2,'w') as f:
f.writelines(role2)
with open(file1,'w') as e:
e.writelines(role1)
def split_(filename):
role1=[ ]
role2=[ ]
count=1
with open(filename) as a:
for eachlines in a:
if eachlines[:6] != '======':
[name,lines]=eachlines.split(':',2)
if name=='赵敏 ':
role1.append(lines)
else:
role2.append(lines)
else:
save_(role1, role2,count)
role1=[ ]
role2=[ ]
count+=1
save_(role1, role2,count)
split_('倚天屠龙记_编剧:右前方.txt')