014_v2 python基础语法_dict
#coding:utf-8 dict = { "name" : "zhang_san", "age" : 24, "subject_list" : ("English", "Chinese", "Math"), "subject_content" : { 'English' : 88, "Chinese" : 92, "Math" : 100 } } print(dict) # 增 dict["sex"] = "man" print(dict) # 删 del(dict["name"]) print(dict) # 改 dict["age"] = 22 print(dict) # 查 print(dict["subject_list"]) # 查询 : 字典中字典 print(dict["subject_content"]["English"])
{'name': 'zhang_san', 'age': 24, 'subject_list': ('English', 'Chinese', 'Math'), 'subject_content': {'English': 88, 'Chinese': 92, 'Math': 100}} {'name': 'zhang_san', 'age': 24, 'subject_list': ('English', 'Chinese', 'Math'), 'subject_content': {'English': 88, 'Chinese': 92, 'Math': 100}, 'sex': 'man'} {'age': 24, 'subject_list': ('English', 'Chinese', 'Math'), 'subject_content': {'English': 88, 'Chinese': 92, 'Math': 100}, 'sex': 'man'} {'age': 22, 'subject_list': ('English', 'Chinese', 'Math'), 'subject_content': {'English': 88, 'Chinese': 92, 'Math': 100}, 'sex': 'man'} ('English', 'Chinese', 'Math') 88