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)

 

相关文章
|
4月前
|
算法 定位技术 C语言
【python实操】软件安装进展提示进度条如何实现的?如何设置窗体拉伸?如何获取输入框内容?
【python实操】软件安装进展提示进度条如何实现的?如何设置窗体拉伸?如何获取输入框内容?
78 0
|
4月前
|
数据可视化 Python
六种酷炫Python运行进度条
六种酷炫Python运行进度条
|
1月前
|
数据可视化 Python
用Python给代码安个进度条,太香了吧
用Python给代码安个进度条,太香了吧
42 4
用Python给代码安个进度条,太香了吧
|
22天前
|
Python
在Python中妥善使用进度条
在Python中妥善使用进度条
|
1月前
|
数据处理 UED Python
Python 进度条:告别枯燥等待,让你的程序动感十足!
Python 进度条:告别枯燥等待,让你的程序动感十足!
65 1
|
22天前
|
监控 API Python
Python中关于进度条的6个实用技巧
Python中关于进度条的6个实用技巧
|
1月前
|
Python
Python 进度条 tqdm模块
Python 进度条 tqdm模块
11 0
|
3月前
|
Python
Python GUI进度条
Python GUI进度条
32 3
|
2月前
|
UED Python
tqdm进度条函数使用 python
tqdm进度条函数使用 python
|
3月前
|
Python
【Python 训练营】N_11 模拟进度条
【Python 训练营】N_11 模拟进度条
18 1