Skip to main content
 首页 » 编程设计

python-2.7之如何突破python shell :

2025年05月04日15bjzhanghao

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

>>>type(''') 

在这一点上,无论我做什么,我输入的所有内容都被视为字符串。什么命令可以让我导致错误并返回到正常的 shell,或者更好的是,彻底中断并返回到正常的 shell?

请您参考如下方法:

您使用 ''' 三重引号开始了一个字符串值。

使用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'>