python-directory
#!/usr/bin/python
# --*-- coding: utf-8 --*--
directory={
"张三":16,
"李四":46,
"王二":56,
"赵武":32,
"小白":12
}
#定义一个空的字典
dire={}
print(type(dire))
#输出整个字典
print(directory)
#修改字典value,若key不存在会报错
directory["张三"]="17"
#获取字典中key为haha的value,若不存在,返回NONE
print(directory.get('haha'))
#打印字典中所有的key
for i in directory:
print(i,"---->",character[i])
#删除字典中key为‘’小白‘’的那一段key-value
directory.pop('小白')
#打印字段长度
print(len(directory))
print(type(directory))
print(directory)
我们之间的距离很近,但又很遥远