(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.
更多推荐
发布评论