1、len
info = {"name":'刘伟达','age':18,'gender':'男','hobby':'同桌'}
print(len(info))
2、索引
info = {"name":'刘伟达','age':18,'gender':'男','hobby':'同桌'}
info['name']
info['age']
3、切片【无】
4、步长【无】
5、for
info = {"name":'刘伟达','age':18,'gender':'男','hobby':'同桌'}
for item in info.keys():
print(item)
for item in info.values():
print(item)
for k,v in info.items():
print(k,v)
6、修改
(存在修改/不存在增加)
# 改值
info = {"name":'刘伟达','age':18,'gender':'男','hobby':'同桌'}
info['age'] = 19
print(info)
# 改键
# 删除后再增加
del info['hobby']
info['xxxxx'] = 'x1'
7、删除
info = {"name":'刘伟达','age':18,'gender':'男','hobby':'同桌'}
del info['name']
print(info)
标签:info,伟达,name,17,age,公共,print,hobby,字典
From: https://www.cnblogs.com/jhchena/p/18432177