!/usr/bin/env python
coding:utf-8
people = {
'yangge': {
'phone': '2341',
'addr': 'BeiJing'
},
'leige': {
'phone': '3158',
'addr': 'ShanDong'
},
'qiangge': {
'phone': '4556',
'addr': 'ShanXi'
},
'shark': {
'phone': '9102',
'addr': 'HeNan'
},
}
可以通过 输入员工的名字,查询到员工的相关信息
比如 先输入名,然后展示处这个员工都有那些信息 [addr phone]
再提示输入具体的信息类型,打印出对应的信息
print("员工")
for i in range(len(people.keys())):
print(list(people.keys())[i])
print('*' * 20)
while True:
name = input("输入员工的名字:")
name = name.strip()
if name in people.keys():
info = input(list(people.get(name)))
info = info.strip()
if info in people.get(name).keys():
print(people.get(name).get(info))