首页 > 解决方案 > Spyder 4:IPython 控制台中的向上/向下箭头(滚动程序输入)

问题描述

我在 2020 年 12 月升级到 Spyder 4.2.0。以前我使用 Spyder 3.x。我从 IPython 控制台中的编辑器运行我的代码。它们是提示控制台输入的简单程序。它类似于从命令行 ( python program.py args) 运行。

当我进行测试时,我经常使用相同输入的不同组合(例如用户名)。使用 Spyder 3.x,我可以在运行程序时使用向上/向下箭头向后滚动以前的输入,以重用以前输入的值。我不知道如何使用 Spyder 4 获得相同的行为。下面的代码块中显示了一个示例。

runfile('E:/walker/optimization/test_prog.py', args='../large', wdir='E:/walker/optimization')
Loading data...Data loaded.
Input Name1: [I input the 1st name]
Input Name2: [I input the 2nd name]
Some printed output here...

Now the program prompts for new input...
Input Name1: [I want to reenter name2 above by going back with the up arrow]
Input Name2: [I want to reenter name1 above by going back with the up arrow]

我不知道如何用 Spyder 4.x 做到这一点。我怀疑从 Spyder 3 升级后发生了一些变化。我查看了IPythonRun in Tools/Preferences的设置。没有提到箭头或滚动输入。
注意:当我在控制台中编码并想要检索以前的 Python 命令时,在控制台中滚动可以正常工作。此问题特定于从编辑器运行代码时的程序输入。

标签: pythonipythonspyder

解决方案


推荐阅读