python异常处理时报错,提示:HTTPError: HTTP Error 404: Not Found
importurllib.requesturl='https://t1.onvshen.com:85/gallery/26120/26667/s/001.jpg1'try...
import urllib.request
url='https://t1.onvshen.com:85/gallery/26120/26667/s/001.jpg1'
try:
url=urllib.request.urlopen(url)
except HTTPError as e:
print("the server cannot fulfill the request")
print("Error code:",e.code)
except URLError as e:
print("we failed to reach a server")
print("reason:",e.reason)
else:
print('it is fine') 展开
url='https://t1.onvshen.com:85/gallery/26120/26667/s/001.jpg1'
try:
url=urllib.request.urlopen(url)
except HTTPError as e:
print("the server cannot fulfill the request")
print("Error code:",e.code)
except URLError as e:
print("we failed to reach a server")
print("reason:",e.reason)
else:
print('it is fine') 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询