对文件内容去重后写入另一文件:
vi a1.py
#!/usr/bin/python
list = []
f = open(‘/root/ming.txt‘,‘r‘)
for str1 in f.readlines():
if not str1 in list:
list.append(str1)
f.close()
for b in list:
f2 = open(‘/root/ming2.txt‘,‘a‘)
f2.write(b)
f2.close()
:wq
python a1.py
原文地址:http://blog.51cto.com/yangzhiming/2132885
时间: 2024-10-07 01:07:57