# 异常处理都在urllib.error中进行处理import urllib.requestimport urllib.error# 第一种异常:该网址不存在url = "http://www.maodan.com/"try: response =urllib.request.urlopen(url)# Exception是所有异常类的基类except Exception as e: print(e)print("毛蛋访问完毕")# 输出结果:# <urlopen error [Errno 11004] getaddrinfo failed># 毛蛋访问完毕# 第二种异常:404url404 = "https://blog.csdn.net/qq_36350532/article/details/79525149"try: response = urllib.request.urlopen(url404)except Exception as e: print(e)print("404访问完毕")# 输出结果# HTTP Error 404: Not Found# 404访问完毕
转载于:https://www.cnblogs.com/kuangkuangduangduang/p/10369888.html
相关资源:各显卡算力对照表!
转载请注明原文地址: https://win8.8miu.com/read-9073.html