python requests 上传文件

token="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjoiZWM2ZWFjZjFjM2UzYzEyOWU3ODA4YjgwNzkxNGIzZjMiLCJleHAiOjE1NTU0OTE3MTIsImlhdCI6MTU1NDg4NjkxMn0.L_Xle5jhSEQbKpJ2bvQcMmo6mVqNgR6Yz30W5AElINk"
headers["Authorization"]=token
url="https://api.mk.xxx.com/openapi/robots/pearl/"+xxx+"/maps"
files = {'file': open(mapsname+'.tar.gz', 'rb')}
response = requests.post(url, headers=headers,files=files)
result=response.json()
print(result)

参考:http://docs.python-requests.org/en/master/user/quickstart/#make-a-request

上一篇:使用PowerDesigner15在win7下的系统MySQL p相反roject(一)


下一篇:linux 下安装memcached与php的memcache扩展