在 CLI 应用程序中创建进度条
当使用 bzr
、doxygen
和 scp
或 wget
等工具时,我发现它们都取得了不错的进展 。
|=============>---------| 55% ETA 3:30
我尝试使用 \b
字符在 C++ 中编写类似的内容,就像我以前写过的内容一样多次 输出闪烁得非常严重,并且看起来不像上述工具那样平滑。
如何用Python顺利地创建这样一个进度条(或者至少改变显示的ETA)?
When using tools like bzr
, doxygen
and scp
or wget
, I see that all of them have a nice progress bar that looks like this:
|=============>---------| 55% ETA 3:30
I tried writing something like that in C++ using the \b
character as many times as I had written something out before. The output was flickering pretty badly and did not look nearly as smooth as the mentioned tools do.
How can I create such a progress bar (or at least change the displayed ETA) with Python smoothly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用“\r”将光标发送到行首。每秒重印次数不要超过 2-3 次,以避免闪烁。
Use "\r" to send the cursor to the beginning of the line. Reprint no more than 2-3 times per second to avoid flickering.
这可能是有用的示例:
http://code .google.com/p/corey-projects/source/browse/trunk/python2/progress_bar.py
this might be useful example:
http://code.google.com/p/corey-projects/source/browse/trunk/python2/progress_bar.py