
person = {"name": "John", "age": 30, "city": "New York"}
print("最开始的信息:",person)
def process_person_info(person):
# 检查对象中是否包含所有必要的键
if 'name' in person and 'age' in person and 'city' in person:
# 打印对象的信息
print(f"Name: {person['name']}")
print(f"Age: {person['age']}")
print(f"City: {person['city']}")
else:
# 如果对象不包含所有必要的键,打印错误信息
print("The person object is missing some information.")
name = input("Please enter the person's name: ")
age = input("Please enter the person's age: ")
city = input("Please enter the person's city: ")
# 更改信息
person_info = {
"name": name,
"age": age,
"city": city
}
# 调用函数
process_person_info(person_info)
结果输出:
最开始的信息: {'name': 'John', 'age': 30, 'city': 'New York'}
Please enter the person's name: JJ
Please enter the person's age: 56
Please enter the person's city: 秘密
Name: JJ
Age: 56
City: 秘密



















