如何突破python shell:

时间:2013-11-12 18:41:12

标签: python-2.7 python

所以我基本上是在摆弄我的python shell(python 2.7)并输入以下内容

>>>type(''')

此时无论我做什么,我输入的内容都被视为字符串。什么命令将允许我导致错误并返回到正常的shell,甚至更好,干净地打破并返回正常的shell?

2 个答案:

答案 0 :(得分:5)

您使用'''三重引号启动了字符串值。

使用 CTRL - C CTRL - D 打破输入循环,或关闭用''')打开引号和括号:

>>> type(''')
... Oops
... What now?
... ^C
  File "<stdin>", line 3
    What now?
            ^
SyntaxError: EOF while scanning triple-quoted string literal
>>> type(''')
... Or you can just close the string and function call!
... ''')
<type 'str'>

答案 1 :(得分:2)

您需要使用CTRL-C。然后,如果你想离开python shell,你可以使用exit()

相关问题