如果我在python intepreter中输错了命令,有时我只是看到....例如,如果我输入help(random.unif并按回车键,则无法输入新命令.我必须退出emacs并再次启动python和解释器.有没有办法纠正这个?
正如Pavel Anossov所解释的那样,您希望向Python发送一个CTRL-C来中断它.
但是在emacs中,默认情况下CTRL-C是前缀键.
幸运的是,在大多数交互式shell模式中,包括python-mode和替代方案,CTRL-C连续两次命令会向解释器发送一个ctrl-C.或者,技术上更有CTRL-CCTRL-C必要comint-interrupt-subjob.(当然,您可以以任何其他方式运行它 - 即使META-X comint-interrupt-subjob您真的想要.)结果如下所示:
Python 2.7.2 (default, Jun 20 2012, 16:23:33)
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> help(f
... ^C ^C
KeyboardInterrupt
>>>
Run Code Online (Sandbox Code Playgroud)
另一种方法是使用quoted-insert命令,通常绑定CTRL-Q,然后命中CTRL-C.但是,因为这不会中断通常的行输入,所以通常必须使用换行符.结果如下:
Python 2.7.2 (default, Jun 20 2012, 16:23:33)
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> help(f
... ^C
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
KeyboardInterrupt
>>>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1161 次 |
| 最近记录: |