小练习
1.想办法打印出jason
l1 = [11, 22, 'kevin', ['tony', 'jerry', [123, 456, 'jason']]]
l2 = l1[3] # l2 = ['tony', 'jerry', [123, 456, 'jason']]
l3 = l2[2] # l3 = [123, 456, 'jason']
print(l3[2])
2.想办法打印出大宝贝
d1 = {'name': 'jason', 'others': {'a1': 'heiheihei', 'a2': {'k1': 'hahaha', 'k2': 'hehehe', 'k3': '大宝贝'}}}
d2 = d1['others'] # d2 = {'a1': 'heiheihei','a2': {'k1': 'hahaha','k2': 'hehehe','k3': '大宝贝'}}
d3 = d2['a2'] # d3 = {'k1': 'hahaha','k2': 'hehehe','k3': '大宝贝'}
print(d3['k3'])
3.想办法打印出run
data = {'username': 'jason', 'hobby': [11, 22, {'height': 183, 'hobby': ['read', 'run', 'music']}]}
data1 = data['hobby'] # data1 = [11, 22, {'height': 183,'hobby': ['read' 'run','music']}]
data2 = data1[2] # data2 = {'height': 183,'hobby': ['read' 'run','music']}
data3 = data2['hobby'] # data3 = ['read' 'run','music']
print(data3[1])
标签:run,read,练习,k3,music,hobby,jason
From: https://www.cnblogs.com/xm15/p/16724161.html