我想從JSON響應訪問session_key。在登錄api我發送憑證回覆Content-Type: application/json
我需要訪問session_key。如何訪問json響應的session_key。如何訪問Django中的json數據?
credential["username"]="john"
credential["password"]="xxx"
response =c.put('/api/login', data=json.dumps(credential))
輸入反應JSON
print response.content
輸出
{"message": "", "result": {"username": "john", "session_key": "xyx"}}
當我試圖用打印(response.content.result)得到錯誤AttributeError: 'str' object has no attribute 'result'