📜  python 检测互联网连接 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:39.307000             🧑  作者: Mango

代码示例2
import urllib2

def internet_on():
    try:
        urllib2.urlopen('http://216.58.192.142', timeout=1)
        return True
    except urllib2.URLError as err: 
        return False