简体   繁体   English

Python tarfile 库 - @PaxHeader 文件

[英]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 .我想打包两个目录: 12

But after executing script I get the archive with 3 directories - 1 , 2 , .但是在执行脚本后,我得到了包含 3 个目录的存档 - 12. . .

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 打包目录时,没有这些相同的文件。

  1. Can I pack directories without these system files via Python tarfile?我可以通过 Python tarfile 打包没有这些系统文件的目录吗?
  2. What are these 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:如 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.

相关问题 python tarfile 创建了一个额外的@PaxHeader 文件并导致错误无法 utime:不允许操作 - python tarfile created an extra @PaxHeader file and cause error Cannot utime: Operation not permitted Python 3.5 tarfile库lzma compresslevel - Python 3.5 tarfile library lzma compresslevel 使用 python 解压文件并使用 tarfile.extractall() python 提取某些文件 - Untar files with python and extract certain files with tarfile.extractall() python Python tarfile和zipfile生成具有不同MD5的档案,用于2个相同的文件 - Python tarfile and zipfile producing archives with different MD5 for 2 identical files 使用 tarfile (Python) 仅压缩给定目录中的文件 - Compressing only the files inside a given directory using tarfile (Python) 在Python中使用tarfile.open()时打开文件的顺序 - Order of opening files when using tarfile.open() in Python 获取python tarfile以跳过没有读取权限的文件 - Get python tarfile to skip files without read permission python TarFile.extractall 命令删除目标目录下的文件 - python TarFile.extractall command deletes the files in the target directory 使用 python 请求库的帖子上传 tarfile - Uploading tarfile using python requests library's post 如何在不添加目录层次结构的情况下使用 Python 将文件添加到 tarfile? - How can files be added to a tarfile with Python, without adding the directory hierarchy?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM