4
许多zip档案(尤其是那些包括OS X应用程序)包含符号链接。在使用zipfile.extractall
方法时,符号链接将转换为常规文件。任何人都知道如何将它们保留为链接?如何在使用Python解压缩存档时保留符号链接?
许多zip档案(尤其是那些包括OS X应用程序)包含符号链接。在使用zipfile.extractall
方法时,符号链接将转换为常规文件。任何人都知道如何将它们保留为链接?如何在使用Python解压缩存档时保留符号链接?
不使用extractall方法。你需要手动完成,可能只是看看something like this(除非你提取不压缩)。
似乎没有办法使用zipfile模块执行此操作。我解决它使用子模块:
from subprocess import check_output, CalledProcessError, STDOUT
try:
check_output(['unzip', '-q', my_zipfile, '-d', destination], stderr=STDOUT)
...
except CalledProcessError as err:
(use err.cmd, err.returncode and err.output to take action)