开发者

Getting the error text from `urllib2.urlopen`

开发者 https://www.devze.com 2023-03-08 09:32 出处:网络
I us开发者_StackOverflow中文版ed Python\'s urllib2.urlopen and got a 500 error from the server. How do I find the text of the error? I\'m hoping that it has useful information.from urllib2 import urlo

I us开发者_StackOverflow中文版ed Python's urllib2.urlopen and got a 500 error from the server. How do I find the text of the error? I'm hoping that it has useful information.


from urllib2 import urlopen, HTTPError

try:
    f = urlopen(url)
except HTTPError, e:
    print(e.read())
0

精彩评论

暂无评论...
验证码 换一张
取 消