我試圖讓在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