Python,按任意键退出 [英] Python, Press Any Key To Exit
问题描述
因此,正如标题所述,我想要一个正确的代码来关闭我的python脚本.
到目前为止,我已经使用input('Press Any Key To Exit')
了,但是这样做会产生一个错误.
我想要一个无需关闭即可关闭脚本的代码.
So, as the title says, I want a proper code to close my python script.
So far, I've used input('Press Any Key To Exit')
, but what that does, is generate a error.
I would like a code that just closes your script without using a error.
有人有想法吗? Google给了我输入选项,但我不想要 它因以下错误而关闭:
Does anyone have a idea? Google gives me the input option, but I don't want that It closes using this error:
Traceback (most recent call last):
File "C:/Python27/test", line 1, in <module>
input('Press Any Key To Exit')
File "<string>", line 0
^
SyntaxError: unexpected EOF while parsing
推荐答案
您是否尝试过raw_input()
?可能是您在python 2.x上使用input()
时遇到了语法错误,这将尝试eval
取得的结果.
Have you tried raw_input()
? It could be that you are getting a syntax error by using input()
on python 2.x, which will try to eval
whatever it gets.
这篇关于Python,按任意键退出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!