我想知道 pycurl 中这个 curl 命令的等价物:
curl --data-binary @binary_data_file.bin 'http://server/myapp/method'
注意:上面的curl语句使用了POST方法。我需要使用它来与我的服务器脚本兼容。
最佳答案
requests
库旨在让事情变得简单:
import requests
r = requests.post('http://server/myapp/method', data={'aaa': 'bbb'})
或者根据接收端对数据的期望:
import requests
r = requests.post('http://server/myapp/method',
data=file('binary_data_file.bin','rb').read())
关于python - pycurl 相当于 "curl --data-binary",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11444257/