作业13:字典dict嵌套及升级作业讲解

dic = {
    'name':['风花雪月','百炼成钢'],
    'py1':{'num':'dir','avg_age':18,},
    True:1,
    (1,2,3):'m',
    2:'凤凰',
    'age':16
}

# dic['age'] = 18
# print(dic)
# {'name': ['风花雪月', '百炼成钢'], 'py1': {'num': 71, 'avg_age': 18}, True: 1, (1, 2, 3): 'm', 2: '凤凰', 'age': 18}
# dic['name'].append('hehehe')
# print(dic)
# {'name': ['风花雪月', '百炼成钢', 'hehehe'], 'py1': {'num': 71, 'avg_age': 18}, True: 1, (1, 2, 3): 'm', 2: '凤凰', 'age': 18}

# dic['py1']['num'] = dic['py1']['num'].upper()
# print(dic)

  

猜你喜欢

转载自www.cnblogs.com/elsa2007/p/10923864.html
0条评论
添加一条新回复