我正在运行CentOS 7.x,我遇到了一些用户键入箭头键的奇怪字符。输入任何其他角色都可以。
我注意到当我从虚拟环境或IDLE3.5中运行交互式shell时,不会发生此问题。它只发生在我使用./testinput.py或python3.5 testinput.py执行脚本时。关于如何解决这个问题的任何想法?
运行脚本
(virtual) $ ./testinput.py
Type: asdf^[[D^[[D # 2 left arrows pressed
Interactive Shell
(virtual) $ python
Python 3.5.2 (default, Nov 22 2016, 19:03:10)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> userinput = input ('Type: ')
Type: as|df # Cursor moved between s and d without weird characters
IDLE
>>> userinput = input ('Type: ')
Type: as|df # Cursor moved between s and d without weird characters