gpt4 book ai didi

Python ZipFile 模块缓慢提取受密码保护的 zip

转载 作者:太空狗 更新时间:2023-10-30 01:14:59 25 4
gpt4 key购买 nike

我正在尝试编写一个 python 脚本,它应该提取一个 zip 文件:

主板:Beagle-Bone black ~ 1GHz Arm-Cortex-a8,debian wheezyZipfile:/home/milo/my.zip, ~ 8 MB

>>> from zipfile import ZipFile
>>> zip = ZipFile("/home/milo/my.zip")
>>> zip.extractall(pwd="tst")

打开和读取的其他解决方案-> 写入 zip 文件并解压特定文件具有相同的效果。提取大约需要 3-4 分钟。

仅使用 unzip-tool 提取相同的文件只需不到 2 秒。

有谁知道我的代码,甚至是 python zipfile lib 是什么?

谢谢阿 java

最佳答案

这似乎是 Python 2.7 中 ZipFile 模块的记录问题。如果您查看 documentation for ZipFile ,它清楚地提到:

Decryption is extremely slow as it is implemented in native Python rather than C.

如果您需要更快的性能,您可以从您的代码中调用外部程序(如 unzip 或 7zip),或者确保您正在使用的 zip 文件没有密码保护。

关于Python ZipFile 模块缓慢提取受密码保护的 zip,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25600432/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com