0
$ curl -F [email protected] -F 'data={"title":"some title","otherinfo" : "aabcdef"}' https://someurl
以上是從終端進行工作和正確的方法。Python請求 - 根據給定的捲曲請求格式數據
我試着使用要求這樣蟒蛇來實現這一點:
files = {'myfile': open('myfilename', 'rb')}
data = {}
data['data'] = {
'title' : 'some title',
'otherinfo' : 'other info'
}
r = requests.post(url, files=files, data=data, auth=auth)
這裏,數據不能正常到達目的地,在那裏我錯了?
這是什麼意思*沒有正確到達目的地*?服務器在使用curl時會收到什麼,以及在使用請求時會收到什麼? –
使用curl時,正確到達,但使用請求時,服務器不識別數據bcoz它希望數據處於正確的形式。如果你從捲曲中看到數據就像-F'data = ...'。我想要它的等價使用請求。我試着發送確切的字符串'data = ..',就像data =「與curl strng相同」,但是這個請求不允許這樣,我試過json.dumps(data),但是沒有用 – user1767962