亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

從 GitHub (urllib.request) 下載 csv 文件時出錯

從 GitHub (urllib.request) 下載 csv 文件時出錯

瀟瀟雨雨 2023-06-13 10:43:24
我已經研究這個腳本幾個星期了,我剛剛完成,一切都運行良好。我返回腳本并嘗試運行它,但我遇到了一個錯誤并且知道它的含義以及如何解決它。當我下載一些包含 CoronaVirus 數據的 csv 文件時,腳本很早就出現了錯誤。我正在使用 urllib.request 來執行此操作,但出現錯誤  File "Run.py", line 13, in <module>    urllib.request.urlretrieve(url, filename="time_series_covid19_recoveredGlobal.csv")  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 247, in urlretrieve    with contextlib.closing(urlopen(url, data)) as fp:  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 222, in urlopen    return opener.open(url, data, timeout)  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 525, in open    response = self._open(req, data)  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 542, in _open    result = self._call_chain(self.handle_open, protocol, protocol +  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 502, in _call_chain    result = func(*args)  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 1362, in https_open    return self.do_open(http.client.HTTPSConnection, req,  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 1322, in do_open    raise URLError(err)urllib.error.URLError: <urlopen error [Errno 8] nodename nor servname provided, or not known>
查看完整描述

1 回答

?
Smart貓小萌

TA貢獻1911條經驗 獲得超7個贊

您的網址有拼寫錯誤:


而不是域是githubuserxxxent.com,他們應該是githubusercontent.com。


請注意,嘗試在瀏覽器中訪問它時githubuserxxxent.com會返回錯誤。Address not found


也許您在代碼中進行了查找和替換,這就是發生這種情況的原因。


固定代碼:


import urllib.request

url = "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_recovered_global.csv"

urllib.request.urlretrieve(url, filename="time_series_covid19_recoveredGlobal.csv")

url = "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv"

urllib.request.urlretrieve(url, filename="time_series_covid19_confirmed_global.csv")

url = "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_deaths_global.csv"

urllib.request.urlretrieve(url, filename="time_series_covid19_deaths_global.csv")



查看完整回答
反對 回復 2023-06-13
  • 1 回答
  • 0 關注
  • 227 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號