f = open("record.txt")
boy = []
girl = []
count = 1
for each_line in f:
-----if each_line[:6] != "======":
----------(name,content) = each_line.split(':',1) # 字符串分割
-----------------if name == '小甲鱼':
------------------------boy.append(content)
------------------else:
-----------------------girl.append(content)
------else:
---------------boy_file_name = 'boy_' + str(count) + '.txt'
---------------girl_file_name = 'girl_' + str(count) + '.txt'
---------------boy_file = open(boy_file_name,'w') #创建文件
----------------girl_file = open(girl_file_name,'w')
----------------boy_file.writelines(boy)
----------------girl_file.writelines(girl)
----------------boy = []
-----------------girl = []
-----------------count += 1
-----boy_file_name = 'boy_' + str(count) + '.txt'
-----girl_file_name = 'girl_' + str(count) + '.txt'
----boy_file = open(boy_file_name,'w') #创建文件
----girl_file = open(girl_file_name,'w')
----boy_file.writelines(boy)
---girl_file.writelines(girl)
f.close()