用python示例代码完成以下需求:创建一个字典1对应02q对应10a对应1e;对应27z对应5aenter对应0ef如果在字典中则返回对应的数值
dictionary = {'1': '02', 'q': '10', 'a': '1e', ';': '27', 'z': '5a', 'enter': '0e'}
def get_value(key):
if key in dictionary:
return dictionary[key]
else:
return None
key = input("请输入一个字符或字符串:")
value = get_value(key)
print(value)
运行示例:
请输入一个字符或字符串:f
None
请输入一个字符或字符串:1
02
请输入一个字符或字符串:enter
0e
原文地址: http://www.cveoy.top/t/topic/iSKO 著作权归作者所有。请勿转载和采集!