我试图让在python使用curl POST请求,但下面的脚本卷曲POST请求抛出错误如何使从蟒蛇
import os
first_name1 = "raj"
last_name1 = "kiran"
full_name = "raj kiran"
headline = "astd"
location1 = "USA"
current_company1 = "ss"
curl_req = 'curl -X POST -H "Content-Type: application/json" -d '{"first_name":"{0}","last_name":"{1}","current_company":"{2}","title":"{3}","campus":"","location":"{4}","display_name":"{5}","find_personal_email":"true"}' http://localhost:8090'.format(first_name1,last_name1,current_company1,headline,location1,full_name)
os.popen(curl_req)
错误:
SyntaxError: invalid syntax
如何使上述程序工作?
你为什么要这样做,当你可以使用'request'? –
如何使用请求以上述格式向此http:// localhost:8090发送发布请求? – Mounarajan
阅读http://docs.python-requests.org/en/latest/ – 2016-06-14 10:21:12