我有一个文本文件,里面有一本英语词典,上面列出了如下单词:
Zymome (n.) A glutinous substance, insoluble in alcohol, resembling legumin; --
now called vegetable fibrin, vegetable albumin, or gluten casein.
Zymometer (n.) Alt. of Zymosimeter
Zymophyte (n.) A bacteroid ferment.
正如你所看到的,意思是多行的。有人能帮我用一个程序在文本文件的输入中搜索这个词,并显示这个词的相应含义吗?你知道吗
我试过的代码:
x=raw_input("Enter word: ")
with open('e:\\Python27\\My programs\\dictionary.txt') as file:
data = file.readlines()
for line in data:
if x in line:
print line
谢谢!你知道吗
我想这就是你想要的:
或基于regex的解决方案:
相关问题 更多 >
编程相关推荐