我是一个新手我想实现一个代码,如果我键入文本,它会查看文件内部,并会说如果有匹配的东西,如果不匹配任何东西将显示没有记录但是这下面的代码是不能做出正确的输出任何想法非常感谢你提前输入字符串并在一个文件中搜索Python
input = raw_input("Input Text you want to search: ")
with open('try.txt') as f:
found = False
if input in f:
print "true"
found = True
if not found:
print('no record!')
这甚至不会运行,因为缩进没有意义。 – khelwood