def read_txt3(): global txt3 txt3 = open('重复.txt', 'w') class repetition: @staticmethod def read_txt1(): global text1 with open(r'词.txt', 'r', ) as f: pl = f.read() text1 = pl.split(',') # 用逗号分割str字符串,并保存到列表 @staticmethod def read_txt2(): global text2 with open(r'对比.txt', 'r') as f: pl = f.read() text2 = pl.split(',') # 用逗号分割str字符串,并保存到列表 @staticmethod def look_repetition(): for i in text1: for j in text2: if i == j: txt3.write(i + ',') if __name__ == '__main__': c = repetition() c.read_txt1() c.read_txt2() read_txt3() c.look_repetition()
对比TXT重复数据
最新推荐文章于 2023-10-03 19:39:10 发布