from urllib import request """ 使用代理 """ url = "http://httpbin.org/ip" #設置代理的服務器的ip和端口,以及協議類型 handler = request.ProxyHandler({"http":"121.232.194.71:9000"}) opener = request.build_opener(handler) resp = opener.open(url) print(resp.read())