Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我是新手,刚刚学习 python 编程的技巧,这是我正在尝试做的事情。
我的互联网是通过需要身份验证的代理服务器。如何使用 Python ping 一个网站,例如“www.google.com”并检查它是否成功?
PS我的操作系统是windows
import urllib2 proxy_support = urllib2.ProxyHandler({'http':'http://login:password@my-proxy:port/'}) opener = urllib2.build_opener(proxy_support) try: f = opener.open("http://google.com/") f.read(1) print "Success" except Exception: print "Failed"