更改变量 exit 命名并尝试将其放在try-except块中:
exit
def finishTest(): ex = "notexit" while ex != "exit": try: ex = input("To finish the test type 'exit'") except EOFError: pass exit()
的 OUTPUT 强> :
To finish the test type 'exit'hey To finish the test type 'exit'okay To finish the test type 'exit'bye To finish the test type 'exit'exit Process finished with exit code 0