2024-10-02 12:28:00 发布
网友
我需要找出邮件是否有我字典中的单词,如果有,我需要知道它是哪个单词,这样我就可以打印值,我有:
if any(word in message for word in diccionary):
所以我想做print(diccionary[thatword])。你知道吗
print(diccionary[thatword])
一个快速的选择:
next(word for word in dictionary if word in message)
for word, value in dictionary.items(): if word in message: print(value)
这就是你要找的吗?你知道吗
for key, value in dictionary.items(): if key in message: print(value)
一个快速的选择:
这就是你要找的吗?你知道吗
相关问题 更多 >
编程相关推荐