有5名业界大佬xiaoyun、xiaohong、xiaoteng、xiaoyi和xiaoyang,其QQ号分别是88888、5555555、11111、12341234和1212121,请用字典变量dic保存这些数据。编程实现以下功能:用户输入某一个大佬的姓名后输出其QQ号,如果输入的姓名不在字典中则输出字符串"Not Found"。 In [7]: s1 = 'xiaoyun, xiaohong, xiaoteng, xiaoyi, xiaoyang' s2 = '88888, 5555555, 11111,12341234, 1212121' # 这两个字符串分解后应注意清除多余的空格 .strip()
时间: 2024-01-24 21:17:57 浏览: 120
How to Break MD5 and Other Hash Functions
可以使用以下代码实现:
```python
s1 = 'xiaoyun, xiaohong, xiaoteng, xiaoyi, xiaoyang'
s2 = '88888, 5555555, 11111, 12341234, 1212121'
names = s1.split(", ")
qqs = s2.split(", ")
dic = {}
for i in range(len(names)):
dic[names[i]] = qqs[i]
name = input("请输入业界大佬的姓名:")
if name in dic:
print(dic[name])
else:
print("Not Found")
```
运行结果示例:
```
请输入业界大佬的姓名:xiaohong
5555555
```
阅读全文