gpt4 book ai didi

python - 祝福: how to move cursor to bottom of screen on exit?

转载 作者:行者123 更新时间:2023-11-28 18:25:39 28 4
gpt4 key购买 nike

我正在尝试 Python 脚本的一些光标图形输出,为我的应用程序提供一个漂亮的进度条。

我使用以下方法确保在显示输出之前我的屏幕是空白的。

print term.clear

但是当我的 Python 脚本完成时,我的 shell 提示符会在屏幕顶部输出,覆盖部分进度条。

如何在 Python 脚本退出时将光标移动到图形输出下方?我在退出脚本之前已经尝试过这个:

print term.move(0, term.height-1)

但这似乎被忽略了。我的 shell 在屏幕顶部开始输出。

我不想进入全屏模式,我想在脚本完成后将进度条的最终输出留在屏幕上。

我的环境是:

  • xterm-256 模式下的 OS X 10.10 终端。
  • python 2.7.10
  • 祝福 1.6

最佳答案

我认为您对 term.move() 的论点是倒退的(基于“永久移动”部分 here)。

move()  Parameters are y coordinate, then x coordinate.

试试这个:

print term.move(term.height - 1, 0)

关于python - 祝福: how to move cursor to bottom of screen on exit?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41682698/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com