how to do urlopen over ipv4 by default
问题 What is the way to do urlopen in python such that even if the underlying machine has ipv6 networking enabled, the request is sent via ipv4 instead of ipv6? 回答1: I had a look into the source code. Unfortunately, urllib.urlopen() seems to use httplib.HTTP() , which doesn't even allow setting a source address. urllib2.urlopen() uses httplib.HTTPConnection() which you could inherit from and create a class which by default sets a source address '0.0.0.0' instead of '' . Then you could somehow