参考:https://blog.csdn.net/weixin_42444693/article/details/104475705
https://www.cnblogs.com/caibao666/p/6433864.html
递归删除文件
shutil.rmtree('folder1')
拷贝文件
shutil.copyfile('f1.log', 'f2.log')
压缩文件
#将 /Users/wupeiqi/Downloads/test 下的文件打包放置 /Users/wupeiqi/目录
import shutil
ret = shutil.make_archive("/Users/wupeiqi/wwwwwwwwww", 'gztar', root_dir='/Users/wupeiqi/Downloads/test')
2、python DiffLib 文本内容对比
参考:https://blog.csdn.net/wumingxiaoyao/article/details/115444548
***SequenceMatcher 找出相同 与difflib.Differ 找出不同
import difflib
from difflib import SequenceMatcher
l1 = "Hello, Welcome to CoderzColumn."
l2 = "Welcome to CoderzColumn, Have a Great Learning Day."
seq_mat_with_junk = SequenceMatcher(isjunk=lambda x: x in [",", "."], a=l1, b=l2, autojunk=True)
seq_mat_without_junk = SequenceMatcher(a=l1, b=l2, autojunk=True)
print("similarity with junk:{}".format(seq_mat_with_junk.ratio()))
print("similarity without junk:{}".format(seq_mat_without_junk.ratio()))
# output
similarity with junk:0.5609756097560976
similarity without junk:0.5853658536585366
import difflib
from difflib import Differ
str1 = "I would like to order a pepperoni pizza.n And you?"
str2 = "I would like to order a veggie burger.n And you?"
str1_lines = str1.splitlines()
str2_lines = str2.splitlines()
d = difflib.Differ()
diff = d.compare(str1_lines, str2_lines)
for lines in diff:
print(lines)
***difflib.HtmlDiff 网页显示不同的
import difflib
from IPython import display
a = open("original.txt", "r").readlines()
b = open("modified.txt", "r").readlines()
difference = difflib.HtmlDiff(tabsize=2)
with open("compare.html", "w") as fp:
html = difference.make_file(fromlines=a, tolines=b, fromdesc="Original", todesc="Modified")
fp.write(html)
display.HTML(open("compare.html", "r").read())



