diff --git a/src/final.py b/src/final.py new file mode 100644 index 0000000..a31a3f8 --- /dev/null +++ b/src/final.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +""" +@author: dell +""" +with open("namelist.txt","r",encoding = "UTF-8") as namelist: + names = namelist.readlines() + for i in range(len(names)): + with open("tmp//"+str(names[i])[2:-1:]+".txt","r",encoding = "UTF-8") as f: + lines = f.readlines() + l = eval(lines[0]) + context = '' + for j in range(len(l)): + context += l[j][0] + if l[j][0]: + context += ":" + context += l[j][1] + c1 = context.replace("\t","") + c2 = c1.replace("\n","") + c3 = c2.replace(" ","") + if "狗" in str(names[i]): + with open("狗狗//"+str(names[i])[2:-1:]+".txt","w",encoding = "UTF-8") as f1: + f1.write(c3) + f1.close() + f.close() + else: + if "猫" in str(names[i]): + with open("猫猫//"+str(names[i])[2:-1:]+".txt","w",encoding = "UTF-8") as f1: + f1.write(c3) + f1.close() + f.close() + else: + with open("其他//"+str(names[i])[2:-1:]+".txt","w",encoding = "UTF-8") as f1: + f1.write(c3) + f1.close() + f.close() + namelist.close() +