或者: req = urllib2.Request("http://example.com", data, {'Content-Type': 'application/octet-stream'}) urllib2.urlopen(req) 那也展示了您如何指定数据的Content-Type。
png_data
中。如果您已经将数据存储在内存中,只需在调用urllib2
时使用即可。 - Greg Hewgill