用以下这段代码,来判断网络是否连接
NETWORK_STATUS = True
try:
requests.get('https://www.taobao.com/', timeout=0.1)
except requests.exceptions.ConnectTimeout:
NETWORK_STATUS = False
print(NETWORK_STATUS)
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
参考: http://docs.python-requests.o...