|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- # coding: utf-8
- from urllib.request import urlopen
- url=r"https://media.langtze.com/Nourish Eats.png!page"
- response = urlopen(url)
- filename="e:\\test.png"
- with open(filename, 'wb') as fp:
- fp.write(response.read())
复制代码
在网上搜了一下 urlopen 的基本用法 感觉没啥问题呢
e:\>python ex22.py
Traceback (most recent call last):
File "ex22.py", line 5, in <module>
response = urlopen(url)
File "C:\Python3\lib\urllib\request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "C:\Python3\lib\urllib\request.py", line 531, in open
response = meth(req, response)
File "C:\Python3\lib\urllib\request.py", line 641, in http_response
'http', request, response, code, msg, hdrs)
File "C:\Python3\lib\urllib\request.py", line 569, in error
return self._call_chain(*args)
File "C:\Python3\lib\urllib\request.py", line 503, in _call_chain
result = func(*args)
File "C:\Python3\lib\urllib\request.py", line 649, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad Request
|
|