【问题标题】:Print text into console at specific position在特定位置将文本打印到控制台
【发布时间】:2022-07-22 02:42:15
【问题描述】:

我想使用 python 在 bash 终端的特定位置打印文本。

有没有办法做到这一点?感谢您的帮助。

【问题讨论】:

    标签: python bash


    【解决方案1】:

    我在page 上为您找到了该功能

    import sys
    
    def _print(text, x=0, y=0):
        sys.stdout.write("\033[{};{}H".format(y, x))
        sys.stdout.write("\033[K")
        sys.stdout.write(text)
        sys.stdout.flush()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-10-28
      • 2020-04-24
      • 2013-03-29
      • 1970-01-01
      • 2015-11-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多