shutil文件去重模块
Posted zhaobowen
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了shutil文件去重模块相关的知识,希望对你有一定的参考价值。
# -*- coding:utf-8 -*-
#! python2
import shutil
a=0
readDir = r"D:pycharm-projectmy-project est hefile2018-11-27.sh"
writeDir = r"D:pycharm-projectmy-project est
ew.txt"
# txtDir = "/home/Administrator/Desktop/1"
lines_seen = set()
outfile = open(writeDir, "w")
f = open(readDir, "r")
for line in f:
if line not in lines_seen:
a+= 1
outfile.write(line)
lines_seen.add(line)
print(a)
print(‘
‘)
outfile.close()
print("success")
以上是关于shutil文件去重模块的主要内容,如果未能解决你的问题,请参考以下文章