import urllib3
http = urllib3.PoolManager()
r = http.request(‘GET‘, ‘http://www.baidu.com/‘)
r.status
print(r.data)
fields = {
    ‘foo‘: ‘bar‘,
    ‘fakefile‘: (‘foofile.txt‘, ‘contents of foofile‘),
    ‘file‘: (‘barfile.txt‘, open("/Users/toriycn/Documents/log").read()),
    ‘typedfile‘: (‘bazfile.bin‘, open("/Users/toriycn/Documents/log").read(),
                  ‘image/jpeg‘),
    ‘nonamefile‘: ‘contents of nonamefile field‘,
}
r = http.request_encode_body(‘POST‘,‘127.0.0.1:7259/upload‘,fields,None,True)
print(r.status)python使用urllib3的一个简单的记录。原文:http://my.oschina.net/u/1462124/blog/520656