f = open("C:/Users/Zhao Yuansong/OneDrive/python练习/029/record.txt",encoding='utf-8')
list_temp = f.readlines()
temp = []
i = 0
for each in list_temp:
if each[0:3] == "===":
n = list_temp.index(each)
temp.append(list_temp[i:n])
list_temp.remove(each)
i = n
temp.append(list_temp[i:])
j = 0
while j < len(temp):
for each in temp[j]:
if each[0:3] == "小甲鱼":
a1 = open("C:/Users/Zhao Yuansong/OneDrive/python练习/029/record_boy" + str(j) + ".txt","a",encoding='utf-8')
a1.writelines(each[4:])
elif each[0:3] == "小客服":
a2 = open("C:/Users/Zhao Yuansong/OneDrive/python练习/029/record_girl" + str(j) + ".txt", "a",encoding='utf-8')
a2.writelines(each[4:])
j += 1
我运行了你的代码,完全正常,没有你说的滚字没了,我这边只加了编码,其他都没动 |