简体   繁体   中英

How to break out of the python shell:

So I basically was fiddling with my python shell (python 2.7) and I typed the following

>>>type(''')

at which point regardless of what I do everything I type is treated like a string. What command will allow me to cause an error and return back to the normal shell, or even better, cleanly break and return to the normal shell?

You started a string value with the ''' triple quote.

Use CTRL - C or CTRL - D to break out of the input loop, or close the opening quotes and parenthesis with ''') :

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

You need to use CTRL-C . Then, if you want to leave the python shell, you use exit()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM