From ca52845aa3b62a254945bea19416ceae7d4cdefd Mon Sep 17 00:00:00 2001 From: p36049127 Date: Sat, 10 Jul 2021 21:08:42 +0800 Subject: [PATCH] =?UTF-8?q?=E7=88=AC=E8=99=AB4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/final.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/final.py 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() +