[英]Python requests send image with data
I need send from client image and some data (like position of this image ->x, y) to server, but nothing working.我需要从客户端图像和一些数据(如该图像的位置 -> x, y)发送到服务器,但没有任何效果。
headers = {'Content-Type': 'application/json'}
url = 'http://localhost:9886/images'
payload = {"username" : "Root", "role" : "Admin",
"image" : open('path_to_file/image.pgm', 'rb')}
payload_json = json.dumps(payload)
r = requests.post(url, data = payload_json, headers = headers)
Is there someone with a straightforward answer?有没有人直接回答?
files = {'upload_file': open('file.txt','rb')} files = {'upload_file': open('file.txt','rb')}
r = requests.post(url, files=files) r = requests.post(网址,文件=文件)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.