shutil拆开档案 - 无法解开临时ZIP文件-Python
我正在尝试以以下方式从云存储中下载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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有可能,给定文件甚至不存在,并且给定的错误消息只会使您认为,给定文件是错误的。
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.