直接上代码
压缩多个文件:
with tarfile.open("1582894835.tar.gz","w:gz") as tar:
for line in os.listdir("./1582894835"):
tar.add("./1582894835/"+line,arcname=os.path.basename("./1582894835/"+line))
压缩目录和压缩单个文件:
with tarfile.open("deal_dict.tar.gz","w:gz") as tar:
tar.add("1583302256",arcname=os.path.basename("1583302256"))
网友评论