python3 - 如何创建tar和zip文件
prevdir = os.getcwd()
os.chdir('/tmp/')
print("Compressing files to %s..." % FILE)
with tarfile.open(FILE, "w:gz") as tar:
tar.add(build_path)
os.chdir(prevdir)
收到以下错误:
Traceback (most recent call last): File "./tar_n_upload.py", line 74, in <module> main(sys.argv[1:]) File "./tar_n_upload_vcs.py", line 69, in main with tarfile.open(FILE, "w:gz") as tar: AttributeError: 'TarFile' object has no attribute '__exit__'
我不知道我在这里遗漏了什么。