shutil拆开档案 - 无法解开临时ZIP文件-Python

发布于 2025-02-06 00:53:27 字数 481 浏览 1 评论 0原文

我正在尝试以以下方式从云存储中下载zip文件:


import shutil 

  with tempfile.NamedTemporaryFile(suffix=".zip") as source_zip:
    aws_util.download(my_buicket, "my_folder/design.zip", source_zip)
    shutil.unpack_archive(source_zip.name, "myfile", "zip")

在尝试解开上面步骤中创建的临时zip文件时。 我收到以下错误:

shutil.readerror:c:\ users \ ryan.zhu \ appdata \ local \ temp \ tmppnn80v56.zip不是

我正在使用Windows OS的zip文件。

如何解决它。谢谢

I am trying to download a zip file from the cloud storage in the following manner:


import shutil 

  with tempfile.NamedTemporaryFile(suffix=".zip") as source_zip:
    aws_util.download(my_buicket, "my_folder/design.zip", source_zip)
    shutil.unpack_archive(source_zip.name, "myfile", "zip")

While trying to unpack the temporary zip file created in the step above.
I am getting the following error:

shutil.ReadError: C:\Users\ryan.zhu\AppData\Local\Temp\tmppnn80v56.zip is not a zip file

I am using windows OS.

How to solve it. Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

十雾 2025-02-13 00:53:27

有可能,给定文件甚至不存在,并且给定的错误消息只会使您认为,给定文件是错误的。

It is possible, that given file does not even exist and given error message is only making you think, that given file is somehow wrong.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文