How to get interactive input from user and to be able to use arrowkeys while entering input?

后端 未结 3 553
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-12 04:56

When I do a raw_input() and enter values, I am not able to use my arrow-keys to change stuff... is there any way for doing that?

Thanx readline module helps in line

3条回答
  •  走了就别回头了
    2021-01-12 05:50

    That's not how raw_input() works. It reads a line from the prompt, and then processes it after the newline character.

    The docs are pretty clear: http://docs.python.org/library/functions.html#raw_input

    If you try to throw arrow keys into the mix, your terminal is likely to add those characters to the returned string. Then again, it may not, depending on your operating system. Don't count on it.

    Perhaps you want the readline module?

    http://docs.python.org/library/readline.html#module-readline

提交回复
热议问题