09-Python字典的基础

# 字典是key-value(键 - 值) 对形式,没有顺序,通过键取出值
adict = {'name':'bob','age':30}
print(len(adict))
print('bob' in adict)  # False
print('name' in adict)  # True
print(adict)
adict['email'] = 'aaa@qq.com'
adict['age'] = 25  # 字典中已有key,修改对应的value。
print(adict)

输出:

 


posted @ 2019-05-10 16:11  hejp  阅读(154)  评论(0编辑  收藏  举报