我正在解决这个问题的答案:Python Interactive Shell Type Application
我的代码看起来像这样
def main():
while True:
s = input('> ')
if s == 'hello':
print('hi')
if s == 'exit':
break
if __name__ == "__main__":
main()
如果我运行它并输入 hello,我会得到
File "<string>", line 1, in <module>
NameError: name 'hello' is not defined
我应该如何收听文本,并根据结果调用不同的函数?