使用 python zipfile 归档符号链接 [英] archiving symlinks with python zipfile

查看:37
本文介绍了使用 python zipfile 归档符号链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个脚本可以创建包含符号链接的目录的 zip 文件.一世惊讶地发现 zipfiles 已经压缩了链接而不是链接本身,这就是我想要的预期的.有人知道如何获取 zipfile 来压缩链接吗?

I have a script that creates zip files of dirs containing symlinks. I was surprised to find that the zipfiles have zipped the targets of the links as opposed to the links themselves, which is what I wanted and expected. Anyone know how to get zipfile to zip the links?

推荐答案

zipfile 似乎不支持存储符号链接.将它们存储在 ZIP 中的方式实际上不是格式的一部分 在某些实现中可用作自定义扩展.特别是,Info-ZIP 的实现支持它们,因此您可以委托给它一>.确保您的解压软件可以处理此类档案 - 正如我所说,此功能未标准化.

zipfile doesn't appear to support storing symbolic links. The way to store them in a ZIP is actually not part of the format and is only available as a custom extension in some implementations. In particular, Info-ZIP's implementation supports them so you can delegate to it instead. Make sure your decompression software can handle such archives - as I said, this feature is not standardized.

这篇关于使用 python zipfile 归档符号链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆