为了账号安全,请及时绑定邮箱和手机立即绑定

解压文件时出错 - Jupyter Notebook - Python 2.x -3.x

解压文件时出错 - Jupyter Notebook - Python 2.x -3.x

精慕HU 2023-11-09 21:56:47
我正在尝试从https://www.fec.gov/data/browse-data/?tab=bulk-data下载 .zip 文件,特别是https://www.fec.gov/files/bulk-downloads/2020 /indiv20.zip。压缩后,文件大小为 2.7 GB。下载将在 10 秒内启动并完成。当我尝试解压缩该文件时,我收到以下错误消息。下载到我的本地计算机时,链接会以 .zip 文件形式下载并打开所需的数据。!python --versionPython 3.7.8!curl -O https://www.fec.gov/files/bulk-downloads/2020/indiv20.zip  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current Dload  Upload   Total   Spent    Left  Speed 100   138  100   138    0     0    690      0 --:--:-- --:--:-- --:--:--   690!unzip -a indiv20.zipArchive:  indiv20.zip End-of-central-directory signature not found.  Either this file is not a zipfile, or it constitutes one disk of a multi-part archive.  In the latter case the central directory and zipfile comment will be found on the last disk(s) of this archive. unzip:  cannot find zipfile directory in one of indiv20.zip or indiv20.zip.zip, and cannot find indiv20.zip.ZIP, period. import zipfilewith zipfile.ZipFile("indiv20.zip", 'r') as zip_ref:    zip_ref.extractall()
查看完整描述

2 回答

?
HUX布斯

TA贡献1876条经验 获得超6个赞

看起来 HTTP 服务器正在返回重定向,并将curl“302 Found”消息存储到 indiv20.zip 文件中,而不是实际的 ZIP 数据中。

您可以通过在命令中添加-L(或--location)参数来解决此问题curl,以便它遵循重定向:

$ curl -LO https://www.fec.gov/files/bulk-downloads/2020/indiv20.zip


查看完整回答
反对 回复 2023-11-09
?
米脂

TA贡献1836条经验 获得超3个赞

检查文件的内容。这可能是 html 中的错误消息。(cat indiv20.zip)



查看完整回答
反对 回复 2023-11-09
  • 2 回答
  • 0 关注
  • 92 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信