2024-05-13 22:54:53 发布
网友
我试图在控制台左上角创建一个简单的时钟,每秒更新一次:
def clock(): threading.Timer(1.0, clock).start() print('\033[0;0H' + time.asctime(time.localtime()))
我已经使用colorama包在Windows中启用了ANSI转义序列,但是转义代码似乎只是将光标移动到指定的像素数,而不是移动到指定的位置。
colorama
如何将光标移到位置(0, 0)?
(0, 0)
行和列从1开始,而不是从0开始。
print('\033[1;1H' + time.asctime(time.localtime()))
或更短
print('\033[H' + time.asctime(time.localtime()))
您可能还需要使用ESC-7和ESC-8保存和恢复位置。
有关代码列表,请参见http://ascii-table.com/ansi-escape-sequences-vt-100.php。
巴里
行和列从1开始,而不是从0开始。
或更短
您可能还需要使用ESC-7和ESC-8保存和恢复位置。
有关代码列表,请参见http://ascii-table.com/ansi-escape-sequences-vt-100.php。
巴里
相关问题 更多 >
编程相关推荐