How to extract a single value from JSON response?

前端 未结 3 1972
我在风中等你
我在风中等你 2020-11-27 13:43

First off, I will freely concede to being little more than a clumsy liberal arts guy who is completely self taught in this scripting thing. That said, I am attempting to get

3条回答
  •  遥遥无期
    2020-11-27 14:18

    Extract single value from JSON response Python

    Try this

    import json
    import sys
    
    #load the data into an element
    data={"test1" : "1", "test2" : "2", "test3" : "3"}
    
    #dumps the json object into an element
    json_str = json.dumps(data)
    
    #load the json to a string
    resp = json.loads(json_str)
    
    #print the resp
    print (resp)
    
    #extract an element in the response
    print (resp['test1'])
    

提交回复
热议问题