把 JSON 转换为 Python

  1. import json
  2.  
  3. # some JSON:
  4. x = '{ "name":"Bill", "age":63, "city":"Seatle"}'
  5.  
  6. # parse x:
  7. y = json.loads(x)
  8.  
  9. # the result is a Python dictionary:
  10. print(y["age"])