将Python Progress Bar安装到所有命令提示符窗口大小中
在调整CMD窗口尺寸时,如何在所有命令提示符窗口大小上使进度栏大小在所有命令提示窗口大小上相同,而不会分为一半甚至多次?
def进度栏(流,块,字节剩余):
percent = 100 * (float (bytes remaining) / stream file size)
bar = '█' * int(percent) + '-' * int((100 - percent))
print(f"\r Downloading: |{bar}|{percent:.2f}%", end="\r")
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 os.get_terninal_size(
如果您可以在窗口大小上放在窗口大小上,直到重新绘制为止,那么您就完成了。如果您希望它立即重新绘制,则需要添加一个信号处理程序,以。
如今,您可以只使用一个库,例如 emlighten 包括其他功能,例如颜色和多个进度条。
有一个示例 ftp downloader 在repo中。
You can use os.get_terminal_size() to do that
If you are ok with it being off on a window resize until it's redrawn, then you're done. If you want it to redraw immediately, you need to add a signal handler for signal.SIGWINCH.
Now all that being said, you could just use a library like Enlighten that already handles all of this and includes other features like color and multiple progress bars.
There's an example ftp downloader in the repo.