import timedef progress(percent): if percent > 1: percent = 1 res = int(50 * percent) * \'#\'print(\"\\r[%-50s] %d%%\" % (res, int(100 * percent)), end=\'\')recv_size = 0total_size = 102400while recv_size < total_size: # 下载了1024字节的数据 time.sleep(0.3) recv_size += 1024 # 打印进度条 percent = recv_size / total_size # 1024/333333 progress(percent)
Python:模拟进度条
未经允许不得转载:爱站程序员基地 » Python:模拟进度条