key_words = ("screen", "power", "wifi")
user_input = input("Type: ")
if user_input in key_words:
print ("you should do this...")
当任何用户类型key_words它会工作,但如果用户在句子中进入它的工作原理是这样:如何从python中的用户输入中找到关键字?
Type: screen is not working
>>>
它应该找到关键字“屏幕”,并输入yes但它只是空白。我知道我必须拆分用户的回应,但我如何为最近的Python做这件事?
如果你把''if' break',该'print'将只执行一次。 – GingerPlusPlus