Python打印动态进度条

简介: Python打印动态进度条

示例一

import time
def show_progress(recv_size, total_size):
    while recv_size < total_size:
        time.sleep(0.01)
        recv_size += 10
        percent = recv_size / total_size  # 0.5
        if percent > 1:
            percent = 1
        strvar = int(percent * 50) * "#"
        print("\r[%-50s] %d%%" % (strvar, percent * 100), end="")
show_progress(0, 1000)

示例二

import time
import sys
has_send = 0
total = 1000
def show_progress(has, total):
    rate = float(has) / float(total)
    rate_num = int(rate * 100)
    if rate_num != 0:
        sys.stdout.write("%s%% %s\r" % (rate_num, rate_num * "#"))
while has_send < total:
    time.sleep(0.05)
    has_send += 10
    show_progress(has_send, total)

 

相关文章
|
算法 定位技术 C语言
【python实操】软件安装进展提示进度条如何实现的?如何设置窗体拉伸?如何获取输入框内容?
【python实操】软件安装进展提示进度条如何实现的?如何设置窗体拉伸?如何获取输入框内容?
213 0
|
数据可视化 Python
六种酷炫Python运行进度条
六种酷炫Python运行进度条
|
Linux UED iOS开发
Python中的自定义进度条:从零开始
Python中的自定义进度条:从零开始
|
数据可视化 Python
用Python给代码安个进度条,太香了吧
用Python给代码安个进度条,太香了吧
163 4
用Python给代码安个进度条,太香了吧
|
UED Python
Python requests库下载文件时展示进度条的实现方法
以上就是使用Python `requests`库下载文件时展示进度条的一种实现方法,它不仅简洁易懂,而且在实际应用中非常实用。
486 1
|
Python
在Python中妥善使用进度条
在Python中妥善使用进度条
142 1
|
数据处理 UED Python
Python 进度条:告别枯燥等待,让你的程序动感十足!
Python 进度条:告别枯燥等待,让你的程序动感十足!
601 1
|
监控 API Python
Python中关于进度条的6个实用技巧
Python中关于进度条的6个实用技巧
180 0
|
Python
Python 进度条 tqdm模块
Python 进度条 tqdm模块
152 0

推荐镜像

更多
下一篇
oss云网关配置