Python 将curl PUT转换为requests.PUT

Python 将curl PUT转换为requests.PUT,python,curl,rackspace-cloud,rackspace,Python,Curl,Rackspace Cloud,Rackspace,我想转换curl命令(将本地文件上载到rackspace) 访问python请求。到目前为止,我已经: url = 'http://storage.clouddrive.com/v1/CF_xer7_343/images/hello.jpg' headers = {'X-Auth-Token': 'fc81aaa6-98a1-9ab0-94ba-aba9a89aa9ae'} request = requests.put(url, headers=headers, data={}) 我在哪里指定

我想转换curl命令(将本地文件上载到rackspace)

访问python请求。到目前为止,我已经:

url = 'http://storage.clouddrive.com/v1/CF_xer7_343/images/hello.jpg'
headers = {'X-Auth-Token': 'fc81aaa6-98a1-9ab0-94ba-aba9a89aa9ae'}
request = requests.put(url, headers=headers, data={})
我在哪里指定要上传
屏幕/hello.jpg


我理解curl中的
-T
表示“到FTP服务器”,但我已经搜索了,但找不到提及FTP的内容。

不,
-T
只是表示“上载此文件”,可与FTP一起使用,但不限于此

您只需将文件数据作为
数据
参数上传即可:

with open('screenies/hello.jpg', 'rb') as image:
    request = requests.put(url, headers=headers, data=image)

其中,
data
将为您读取和上载图像数据。

否,
-T
仅表示“上载此文件”,可与FTP一起使用,但不限于此

您只需将文件数据作为
数据
参数上传即可:

with open('screenies/hello.jpg', 'rb') as image:
    request = requests.put(url, headers=headers, data=image)
其中
数据
将为您读取并上传图像数据