Created
November 10, 2017 02:53
-
-
Save Loveforkeeps/3fc216f1d0a7744c986dace90996bd32 to your computer and use it in GitHub Desktop.
合并文件
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 去除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