![](/img/trans.png)
[英]I don't know how to select specific items from jsonnified object in my web application using flask
[英]I don't know how to select specific items from json object in my web application using flask
response = requests.get(url)
response_json = response.json()
results = response_json['a'][0]
output = results['a_1'] + results['a_2'] + results['a_3']
return jsonify(output)
我的 output
“abcdefg”
我想要的是
abcdefg
我應該如何解決它?
jsonify
構建一個 Flask 響應 object。 使用此代碼,您可以像訪問字典一樣訪問它:
results = jsonify( response_json )["results"][0] # bad
我想你正在尋找:
results = jsonify( response_json["results"[0] )
請注意,這里的response_json
實際上是一個 python 數據結構(字典),因為這是response.json
返回的內容。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.