|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
跟着小甲鱼的视频敲的代码,但是在运行时报错,图片也没下载下来,请问这是什么原因导致的?
代码:
import urllib.request
response = urllib.request.urlopen('http://placekitten.com/g/200/300')
cat_img = response.read()
with open('cat_200_300.jpg','wb') as f:
f.write(cat_img)import urllib.request
报错:
Traceback (most recent call last):
File "C:\Users\16285\Desktop\download.py", line 3, in <module>
response = urllib.request.urlopen('http://placekitten.com/g/200/300')
File "C:\Users\16285\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "C:\Users\16285\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 525, in open
response = self._open(req, data)
File "C:\Users\16285\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 542, in _open
result = self._call_chain(self.handle_open, protocol, protocol +
File "C:\Users\16285\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 502, in _call_chain
result = func(*args)
File "C:\Users\16285\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 1348, in http_open
return self.do_open(http.client.HTTPConnection, req)
File "C:\Users\16285\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 1323, in do_open
r = h.getresponse()
File "C:\Users\16285\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 1322, in getresponse
response.begin()
File "C:\Users\16285\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 303, in begin
version, status, reason = self._read_status()
File "C:\Users\16285\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 272, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response
|
|