[英]python TarFile.extractall command deletes the files in the target directory
this is a simple piece of code in our production env.这是我们生产环境中的一段简单代码。 Python version 2.7 Python 2.7版
tar = tarfile.open(fileobj=pipe, mode='r|gz')
tar.extractall(d)
The finally blocks closes the tar file also. finally 块也会关闭 tar 文件。
finally:
if tar:
tar.close()
However, on windows it is observed that some files in the target directory are deleted after the extractall().但是,在 windows 上,观察到目标目录中的一些文件在 extractall() 之后被删除。 Is this possible?这可能吗? has anyone seen such issue before?有没有人见过这样的问题?
Windows is windows 2016 Windows 是 windows 2016
In my experience tarfile.extractall() overwrites files and directories.以我的经验 tarfile.extractall() 会覆盖文件和目录。 If you edit some extracted files and than run again extractall(), you will obtain the "original" files.如果您编辑一些提取的文件,然后再次运行 extractall(),您将获得“原始”文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.