Skip to content

Instantly share code, notes, and snippets.

@Loveforkeeps
Created November 10, 2017 02:53
Show Gist options
  • Save Loveforkeeps/3fc216f1d0a7744c986dace90996bd32 to your computer and use it in GitHub Desktop.
Save Loveforkeeps/3fc216f1d0a7744c986dace90996bd32 to your computer and use it in GitHub Desktop.
合并文件
# 去除domainArchive的无效文件,保证数据合理性
cmd = "find . -name \"*\" -type f -size 0c | xargs -n 1 rm -f"
sub = subprocess.call(cmd,shell=True)
if sub == 0:
print("Clear vaild file success!")
# 获取domainArchive中的domain文件列表
cmd = "ls | grep '[0-9]'"
stdout = subprocess.check_output(cmd,shell=True)
print type(stdout)
# print stdout
domainlist = list()
for i in stdout.split('\n'):
if not i == '':
print i
domainlist.append(i)
domainlist = domainlist[-5::]
print domainlist
with io.open("week.txt","w",encoding="utf8") as f:
for i in domainlist:
with io.open(i,"r",encoding="utf8") as f1:
f.write(f1.read())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment