#! /usr/local/bin/python3
# coding:utf-8
"""
遍历字典 提取key值value
"""
import json
file = "/Users/y50/data"
soulData = open(file , 'r').read()
data = json.loads(soulData)
print ("data type : " , type(data))
print ("data : " , data)
data_key = "name"
for key in data.keys():
if key == data_key:
print (data[key])
print ("测试")
data type :
data : {'name': 'ni', 'city': 'tt', 'id': 2256}
ni
测试
参考: