[英]Python tarfile library - @PaxHeader files
I want to create an archive with Python tarfile library.我想用 Python tarfile 库创建一个存档。
I have wanted to pack two directories: 1
, 2
.我想打包两个目录:
1
、 2
。
But after executing script I get the archive with 3 directories - 1
, 2
, .
但是在执行脚本后,我得到了包含 3 个目录的存档 -
1
、 2
、 .
. .
In test.tar.gz\test.tar\.\.\
I have found many files with the same names: @PaxHeader
.在
test.tar.gz\test.tar\.\.\
我发现了许多同名的文件: @PaxHeader
。
Strange but when I pack directories via CLI there are not these same files.奇怪,但是当我通过 CLI 打包目录时,没有这些相同的文件。
UPDATE :更新:
I use:我用:
with tarfile.open(archive, 'w:gz') as tar:
tar.add(x, x)
Maybe you can try this,add format config.也许你可以试试这个,添加格式配置。
with tarfile.open(archive, 'w:gz',format=tarfile.GNU_FORMAT) as tar:
tar.add(x, x)
As describe in tarfile library:如 tarfile 库中所述:
The default format for creating archives. This is currently PAX_FORMAT.
Changed in version 3.8: The default format for new archives was changed to PAX_FORMAT from GNU_FORMAT.
https://docs.python.org/3/library/tarfile.html https://docs.python.org/3/library/tarfile.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.