简体   繁体   English

如何在循环python emacs时停止无限

[英]How to stop infinite while loop python emacs

I wrote this code: 我写了这段代码:

x = 0
while x == 0:
      print 'd'

When I type Cc! 当我输入抄送! and Cc Cc the code runs. 和Cc Cc代码运行。

Now the question is: How I stop the execution of that code? 现在的问题是:我如何停止执行该代码?

Many thanks for our answers. 非常感谢我们的答案。 Finaly I got the solution. 最后我得到了解决方案。 Here is my step by step how-to. 这是我一步一步的操作方法。

Credits to Omri Barel, Pavel Repin, jmdeldin 归功于Omri Barel,Pavel Repin,jmdeldin

Startpoint is: infinite while loop in pythontests.py file, 开始点是:pythontests.py文件中的无限循环,

  1. Cc ! 抄送! (open the python shell)(you see two windows "buffers", cursor is in the python shell) (打开python shell)(你看到两个窗口“缓冲区”,光标在python shell中)
  2. Cx o (switch to other window "buffer") (now is the pythontests.py file highlited) Cx o(切换到其他窗口“缓冲区”)(现在是pythontests.py文件highlited)
  3. Cc CC (execute the code)(the lines begin to move and count :)) 抄送CC(执行代码)(行开始移动并计数:))
  4. Cx o (switch to other window "buffer") (now is the python shell highlited) Cx o(切换到其他窗口“缓冲区”)(现在是python shell highlited)
  5. Cc Cc (stops running process) (now you see the Trackback message) Cc Cc(停止运行进程)(现在您看到Trackback消息)

In my case I got this message: 就我而言,我得到了这样的信息:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/tmp/python-4684wEr.py", line 3, in <module>
    print 'd'
KeyboardInterrupt

And here is the screencast how it works: http://youtu.be/1MbfCHusF9c 以下是截屏视频的工作方式:http: //youtu.be/1MbfCHusF9c

Switch to the *Python* buffer and type Cq Cc to interrupt the script. 切换到*Python*缓冲区并键入Cq Cc以中断脚本。 Cq ( quoted-insert ) is used to insert control characters because Cc would be intercepted by Emacs. Cqquoted-insert )用于插入控制字符,因为Cc将被Emacs拦截。 It works in the shell modes too. 它也适用于shell模式。

我想你想要Cg停止运行当前命令。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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