kewin-pythonの辞書学習

侯に連絡することができ、より子供向け番組、マイクロチャネルdata_ecology
このリンク: https://blog.csdn.net/houlaos/article/details/102648974
# 字典,  列表 元组 字符串 数字
#{'name':'哥斯拉', 'height':180, 'weight':180}
team = ['百里守约', '曹操', '扁鹊', '诸葛亮', '赵云']
# 键值对
# 增 删 改 查
dict_name = {'name': '哥斯拉', 'height': 180, 'weight': 180}
# 1。查找
print(team[0])
print(dict_name['name'])
# 2。修改
team[4] = '马超'
print(team)
dict_name['name'] = '基多拉'
print(dict_name)
# 3。增加
team.append("亚瑟")
print(team)
dict_name['武器'] = '没有武器'
print(dict_name)
# 4。删除
del team[5]
print(team)
del dict_name['武器']
print(dict_name)

# 5。in
print('马超' in team )
print('name' in dict_name)
# 打印字典的键
print(dict_name.keys())
print(dict_name.values())

おすすめ

転載: blog.csdn.net/houlaos/article/details/102648974