data = {'name':'jack','age':18}
# for in,默认提取字典的键名
for k in data:
print(k)
结果:
name
age
data = {'name':'jack','age':18}
r = data['age']
print(r)
print(data['name'])
结果:
18
jack
# 这种取值方法语法是不对的
# 只能单个取值
a = data['name']['age']
print(a)
dict = {'name':[{'name1':'mak','name2':'losi'}],'age':18}
print(dict['name'])
print(dict['name'][0])
print(dict['name'][0]['name1'])
结果:
[{'name1': 'mak', 'name2': 'losi'}]
{'name1': 'mak', 'name2': 'losi'}
mak