Skip to main content
 首页 » 编程设计

python之为什么有时 python 解释器无法识别向上箭头键

2025年05月04日12think

这个问题真的困扰了我很久,一直想不出答案。

我的 ubuntu 中有各种版本的 python。某些版本的 python 解释器可以 正常识别键盘箭头键。但有些版本不能。

例如。在我的python2.6解释器中,所有的键盘按键都可以正常读取。 但是在我的 python2.7 解释器中,如果我在键盘上键入“向上箭头键”,解释器会显示这个,我想要的是重新出现 >>> test = "hello world":

(python2.7)yarkee@yarkee-laptop:~$ python 
Python 2.7.3 (default, Mar 19 2013, 19:57:37)  
[GCC 4.4.3] on linux2 
Type "help", "copyright", "credits" or "license" for more information. 
>>> test = "hello world" 
>>> ^[[A 

请您参考如下方法:

听起来你的 python-2.6 解释器是用 readline 支持构建的,但你的 python-2.7 解释器不是。