貌似没有现成的函数,可以自己简单实现一下:
import requestsimport jsondef get_my_ISP_address(): ip = 'unkown' try: request_content = requests.get('http://httpbin.org/ip').text ip = json.loads(request_content)['origin'] except Exception, e: print "Error for", e return ipif __name__ == '__main__': print get_my_ISP_address()