如何搜索用户输入并找到特定的关键字,然后在文本文件中搜索此关键字?
这就是我目前所拥有的:
foods = str(input("what takeaway would you like today go sir/madame reply with one word answers"))
with open("pizza.txt", "r") as f:
searchlines = f.readlines()
for i, line in enumerate(searchlines):
if foods in line:
print(line)
字符串
1条答案
按热度按时间qni6mghb1#
你的第一句话意味着你想限制用户输入可能找到的食物。
字符串