Python Putty 中的箭头键返回 ^[[A ^[[D ^[[B 而不是移动光标

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14837248/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-18 12:36:37  来源:igfitidea点击:

Arrow keys in Putty returning ^[[A ^[[D ^[[B instead of moving the cursor

pythonputtyarrow-keys

提问by LittleBobbyTables

Has anyone else ever had this error in PuTTy?

有没有其他人在 PuTTy 中遇到过这个错误?

For example, pressing the Up Key now produces:

例如,现在按下向上键会产生:

>>> ^[[A

Google doesn't let you search for special characters so I'm stumped at finding existing version of this problem.

Google 不允许您搜索特殊字符,因此我很难找到此问题的现有版本。



EDIT:

编辑:

So this happened after I pasted in some unicode (when, I think, the translation was already set to utf-8).

所以这是在我粘贴一些 unicode 之后发生的(我认为,当时翻译已经设置为 utf-8)。

I've checked the Change Settings dialog box for different settings than my other open PuTTy windows, but the settings appear to be identical.

我已经检查了更改设置对话框中与其他打开的 PuTTy 窗口不同的设置,但这些设置似乎是相同的。

EDIT2:

编辑2:

This is fixed by restarting PuTTy, but still a nuisance.

这是通过重新启动 PuTTy 来解决的,但仍然很麻烦。

EDIT3:

编辑3:

How to replicate the exact same bug:

如何复制完全相同的错误:

  1. Open a putty terminal to a linux PC (I'm using RedHat)
  2. Open Python 2.7.* - using the command python2.7(note: error does not appear in 2.6)
  3. import codecs
  4. Now use the arrow keys, and these bizarre characters appear.
  1. 在 Linux PC 上打开一个腻子终端(我使用的是 RedHat)
  2. 打开 Python 2.7.* - 使用命令python2.7(注意:错误不会出现在 2.6 中)
  3. import codecs
  4. 现在使用箭头键,这些奇怪的字符就会出现。

回答by paul

You could try changing the 'Application Cursor Keys' mode. It's in the Terminal->Keyboard subsection of the initial configuration window (these settings may potenitally be overridden by your server).

您可以尝试更改“应用程序光标键”模式。它位于初始配置窗口的“终端”->“键盘”小节中(这些设置可能会被您的服务器覆盖)。

http://the.earth.li/~sgtatham/putty/0.55/htmldoc/Chapter4.html#S4.4.4

http://the.earth.li/~sgtatham/putty/0.55/htmldoc/Chapter4.html#S4.4.4

回答by latheiere

For those interested in the issue, had same simptoms in a virtualenvironment, resolved the issue with

对于那些对这个问题感兴趣的人,在虚拟环境中有同样的问题,解决了这个问题

pip install readlines

See following answerfor details.

有关详细信息,请参阅以下答案

回答by olvlvl

In my experience that's because "bash" is not running. Simply run "/bin/bash" to enjoy colors, history and more.

根据我的经验,这是因为“bash”没有运行。只需运行“/bin/bash”即可享受颜色、历史等。

回答by A.Samiei

Just run the simple bash command or sudo bash in ssh. It usually works.

只需在 ssh 中运行简单的 bash 命令或 sudo bash。它通常有效。

回答by Michael Cameron

I've found that specifying "The Function Keys and Keypad" option to match your operating system resolves many issues.

我发现指定“功能键和键盘”选项以匹配您的操作系统可以解决许多问题。

[Putty]

[油灰]

Terminal -> Keyboard --> RadioButton "Linux"

终端 -> 键盘 --> 单选按钮“Linux”

(if you're using Linux) and then you can start your session

(如果您使用的是 Linux),然后您就可以开始会话了