(python)我在tar.gz文件上使用os.path.join((python) do I use os.path.join on tar.gz files)

编程入门 行业动态 更新时间:2024-10-26 03:36:54
(python)我在tar.gz文件上使用os.path.join((python) do I use os.path.join on tar.gz files)

我有一个tar.gz文件,我想提取某个目录但不是整个目录,所以我使用TarFile.getmember('foo/bar') 。 我想知道的是,我是否真的应该使用TarFile.getmember(os.path.join('foo','bar')) 。

编辑:我也想知道我是否会将os.path.join用于tarfile模块或zipfile moduple中的任何其他函数。

I have a tar.gz file, and I want to extract a certain directory but not the whole thing, so I use TarFile.getmember('foo/bar'). what I want to know is if I really should be using TarFile.getmember(os.path.join('foo','bar')).

edit: I'm also wondering if I would use os.path.join for any other function within the tarfile module or zipfile moduple.

最满意答案

不, getmember的参数是tar文件中的关键,而不是本地文件系统路径。 使用斜杠。

No, the argument to getmember is the key inside the tar file, not a local file system path. Use the slashes.

更多推荐

本文发布于:2023-08-03 05:59:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1384121.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:我在   文件   gz   tar   python

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!