python, Json and string indices must be integers, not str

前端 未结 2 1239
自闭症患者
自闭症患者 2021-01-12 13:22

I am using Python, and I sent a request to a URL and received a reply using httplib2. The reply I got was in JSon, how do I access a specific parameter. What I have at the m

相关标签:
2条回答
  • 2021-01-12 13:50

    You can use dump;

    result = json.dumps(content)
    
    result = json.loads(result)
    
    0 讨论(0)
  • 2021-01-12 13:51

    Well if the response type is json and it comes in type str.

    If you are running 2.4 of Python use simplejson if 2.6 use json:

    import json
    # Your code
      retdict = json.loads(content)
    

    Then treat it like a dictionary.

    accesstoken = retdict['access_token']
    
    0 讨论(0)
提交回复
热议问题