pythonでのreadlineの使い方

1004 ワード

readline
質問:

(.env) [root@cd tmp]# python
Python 2.7.10 (default, Jul  4 2017, 17:45:34)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import time^[[D^[[D^[[D
  File "", line 1
    import time
               ^
SyntaxError: invalid syntax
>>> ^[[A^[[A^[[A^[[B^[[B
  File "", line 1
    ^
SyntaxError: invalid syntax
>>>

戻ることができなくて、上へひっくり返すことができなくて、下へひっくり返すことができません....
readlineのインストール
(.env) [root@cd tmp]# pip install readline

readlineをインストールした後:
(.env) [root@cd tmp]# python
Python 2.7.10 (default, Jul  4 2017, 17:45:34)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import time
>>> import time