使用http库就可以做到
参考:
import http.client
conn = http.client.HTTPConnection(host = '123.56.129.164', port = 8080)
if __name__ == '__main__':
header = {'content-type': 'image/jpeg'}
body = open(u'D:\\test.jpg', 'rb').read();
conn.request('POST', u'User/uploadFile/id/ba1da387-cd13-4ead-b1e7-c7c443840b3a', headers= header, body=body)
#response = conn.getresponse()