如果哦文件xxx里面有重复的文件,为了保证内容不能重复可以运行以下代码,输出文件yyy
fe1 = 'xxx'
fe2 = 'yyy'
f1 = open(fe1, encoding="utf-8")
f2 = open(fe2, "w", encoding="utf-8")
line1 = f1.readlines()
lis = list(set(line1))
print(lis)
f2.writelines(lis)
f2.close()
f1.close()
如果哦文件xxx里面有重复的文件,为了保证内容不能重复可以运行以下代码,输出文件yyy
fe1 = 'xxx'
fe2 = 'yyy'
f1 = open(fe1, encoding="utf-8")
f2 = open(fe2, "w", encoding="utf-8")
line1 = f1.readlines()
lis = list(set(line1))
print(lis)
f2.writelines(lis)
f2.close()
f1.close()