我正在使用 ipdb 调试我的 Python 脚本。不知何故,我遇到了问题,输入命令后,例如 n、s、c、b 等。我必须按两次 Ctrl+D 才能使用 ipdb处理命令并继续。
知道是什么原因造成的以及如何将其关闭吗?
最佳答案
此影响与 ipdb 无关:
从技术上讲,Ctrl-D 会终止传输,并且只有在出现这种情况时才会引发 EOF 在空的输入缓冲区中。仅当您在输入任何内容之前按 Ctrl-D 时才会发生这种情况 字符。
做这个实验:
1. At the linux terminal type cat
2. press enter once.
3. enter letters: foo
4. press <Ctrl-D> once, you don't get back to the terminal.
5. press <Ctrl-D> again, you are brought back to the terminal.
所以它看起来像这样:
user@defiant ~ $ cat
foofoouser@defiant ~ $
foo 被打印两次,因为你第一次按下它会刷新你的输入。第二次则解释为结束程序。
如何阻止这种行为:
按 Ctrl-D 时不要连接到 TTY。这意味着不要使用普通的 Linux 终端。不确定这是否可能。
如何在 ipdb 中处理命令
按 Enter 键应处理命令,如此处视频所示:http://www.gregaker.net/2012/apr/05/debugging-python-with-pdb-or-ipdb/
关于python - ipdb 需要 Ctrl+D 来处理命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14960161/