# coding=utf-8
import sys
import time
# width:宽度, percent:百分比
def progress(width, percent):
print "\r%s %d%%" % (('%%-%ds' % width) % (width * percent / 100 * '='), percent),
if percent >= 100:
print
sys.stdout.flush()
# 示例一、0%--100%
def demo1():
for i in xrange(100):
progress(50, (i + 1))
time.sleep(0.1)
## 示例二、周期加载
def demo2():
i = 19
n = 200
while n > 0:
print "\t\t\t%s \r" % (i * "="),
i = (i + 1) % 20
time.sleep(0.1)
n -= 1
demo1()
demo2()
import time
import thread
import sys
class Progress:
def __init__(self):
self._flag = False
def timer(self):
i = 19
while self._flag:
print "\t\t\t%s \r" % (i * "="),
sys.stdout.flush()
i = (i + 1) % 20
time.sleep(0.05)
print "\t\t\t%s\n" % (19 * "="),
thread.exit_thread()
def start(self):
self._flag = True
thread.start_new_thread(self.timer, ())
def stop(self):
self._flag = False
time.sleep(1)
progress = Progress() progress.start() time.sleep(5) progress.stop()
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有