41 lines
1.6 KiB
Python
41 lines
1.6 KiB
Python
#Boss要求每个人将自己的情况做一个简单的汇报,作为秘书的你做一个程序能够将每个特工的情况汇总成一个系统性的表格。
|
||
#具体要求:通过这个程序特工可以交互式的(input())将自己的信息输入,程序要比对输入的Name,Locations,Communications是否符合
|
||
#实现功能:1.输入信息并自动匹配 2.遍历字典,查看信息是否符合
|
||
|
||
#分析:information.py里面给出了name,locations,communications三个列表
|
||
#需要输入查询信息,是否都存在于对应列表中,都匹配上则提示匹配成功!
|
||
|
||
from information import Name, Locations, Communications
|
||
|
||
# 输入信息
|
||
input_name = input("请输入姓名(Name): ").strip() #strip()去除多余空格
|
||
input_location = input("请输入地点(Location): ").strip()
|
||
input_communication = input("请输入联系方式(Communication): ").strip()
|
||
|
||
# 检查姓名是否有效
|
||
def is_valid_name(name):
|
||
for role in Name["Agent"]["Orientation"].values():
|
||
if name in role:
|
||
return True
|
||
return False
|
||
|
||
# 检查地点是否有效
|
||
def is_valid_location(location):
|
||
for loc_list in Locations.values():
|
||
if location in loc_list:
|
||
return True
|
||
return False
|
||
|
||
# 检查联系方式是否有效
|
||
def is_valid_communication(communication):
|
||
return communication in Communications
|
||
|
||
# 综合验证
|
||
if (
|
||
is_valid_name(input_name) and
|
||
is_valid_location(input_location) and
|
||
is_valid_communication(input_communication)
|
||
):
|
||
print("信息匹配成功!")
|
||
else:
|
||
print("未找到匹配的信息,请检查输入内容。") |