我正在尝试用 Python3 编写控制台应用程序.
I am trying to write a console application in Python3.
问题是我希望所有输出消息 EG: print("Status message") 都位于底部输入行的上方.
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
现在看起来更像这样
Console:> want to type here while the outStatus message 1
put messages displayed
有没有不使用诅咒的方法?
Is there anyway to do this without using curses?
试试这个:
print chr(27)+'[2AOutput'
希望这是您的要求.
抱歉,以上内容适用于 Python 2.7.我不确定是否是 Python 3 版本
Sorry the above is for Python 2.7. I am not sure whether the Python 3 version
print(chr(27)+'[2AOutput')
行不通.
参考:http://en.wikipedia.org/wiki/ANSI_escape_code
这篇关于Python 控制台应用程序 - 输入行上方的输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
如何在 conda 环境中安装 Selenium?How to install Selenium in a conda environment?(如何在 conda 环境中安装 Selenium?)
使用 Anaconda installe 在 Windows 上获取 CUDA 和 CUDNNget the CUDA and CUDNN version on windows with Anaconda installe(使用 Anaconda installe 在 Windows 上获取 CUDA 和 CUDNN 版本)
如何下载适用于 python 3.6 的 AnacondaHow can I download Anaconda for python 3.6(如何下载适用于 python 3.6 的 Anaconda)
使用两个不同的 Python 发行版Using two different Python Distributions(使用两个不同的 Python 发行版)
除了 OSX 上现有的 pyenv 安装之外,如何安装 AnaHow can I install Anaconda aside an existing pyenv installation on OSX?(除了 OSX 上现有的 pyenv 安装之外,如何安装 Anaconda?)
在 Cygwin 中为 Anaconda 永久设置 Python 路径Permanently set Python path for Anaconda within Cygwin(在 Cygwin 中为 Anaconda 永久设置 Python 路径)