Python console application - output above input line

微笑、不失礼 提交于 2019-12-05 20:03:01

问题


I am trying to write a console application in Python3.

The problem is I would like all output messages EG: print("Status message") to be above the input line at the bottom.

Status message 1
Status message 2
Status message 3
Console:> I want to type here while the output messages displayed

at the moment it looks more like this

Console:>  want to type here while the outStatus message 1
put messages displayed

Is there anyway to do this without using curses?


回答1:


Try this:

print chr(27)+'[2AOutput'

Hope this is what you are asking for.

Sorry the above is for Python 2.7. I am not sure whether the Python 3 version

print(chr(27)+'[2AOutput')

will work or not.

Ref: http://en.wikipedia.org/wiki/ANSI_escape_code



来源:https://stackoverflow.com/questions/14300245/python-console-application-output-above-input-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!