I want to create an archive with Python tarfile library.
I have wanted to pack two directories: 1
, 2
.
But after executing script I get the archive with 3 directories - 1
, 2
, .
.
In test.tar.gz\test.tar\.\.\
I have found many files with the same names: @PaxHeader
.
Strange but when I pack directories via CLI there are not these same files.
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:
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.