码迷,mamicode.com
首页 > 编程语言 > 详细

Python判断网络是否可以访问

时间:2018-01-02 23:28:10      阅读:193      评论:0      收藏:0      [点我收藏+]

标签:style   断网   col   div   stat   post   color   访问   http   

import  urllib
url = "http://www.baidu.com"
try:
    status = urllib.urlopen(url).code
    print status
except:
    print {result: false, msg: URL cannot access}

 

Python判断网络是否可以访问

标签:style   断网   col   div   stat   post   color   访问   http   

原文地址:https://www.cnblogs.com/413xiaol/p/8178940.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!