它不会覆盖 linux 终端上打印的最后一行

问题描述 投票:0回答:1

“我”做了一个在 vscode 中运行良好的进度条,但是在 linux 上它只是一遍又一遍地打印它。

(https://i.stack.imgur.com/cDlgJ.png)

我尝试了很多东西( , sys.stdout.write 等)它们都不起作用。我认为缺少的是终端特定语法中的某些内容。奇怪的是有时 % 更新但进度条本身没有

python python-3.x linux progress-bar carriage-return
1个回答
-1
投票

要清除终端中的上一个进度条,您可以使用

os
模块

import os

窗户:

os.system('cls') 

适用于 Linux

os.system('clear')
© www.soinside.com 2019 - 2024. All rights reserved.