![](/img/trans.png)
[英]How to convert x-www-form-urlencoded to json with Python (Django)
[英]how to send application/x-www-form-urlencoded JSON string in python botlle server
我想以以下格式發布JSON字符串
application/x-www-form-urlencoded
使用python的瓶子
這是我編寫的Web服務
import json
from bottle import route, run, request
@route('/ocr_response2', method='POST')
def ocr_response2():
word = request.json
print word
if __name__ == "__main__":
run(host='0.0.0.0', port=8080, debug=True)
我知道如果contentType: "application/json",
可以工作contentType: "application/json",
但是無法確定內容類型是否為application/x-www-form-urlencoded
這是我發送數據的方式
import requests
d = {'spam': 20, 'eggs': 3}
requests.post("http://XX.XX.XX.XXX:8080", data=d)
使用request.forms.get('spam')
同樣在requests.post
URL應該是http://XX.XX.XX.XXX:8080/ocr_response2
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.