第一种方法:
import sys import time def view_bar(num): r = ‘\r[%s%s] %d%%‘ % ("="*num, " "*(100-num), num) sys.stdout.write(r) sys.stdout.flush() if __name__ == ‘__main__‘: for i in xrange(0,101): time.sleep(0.1) view_bar(i)
效果如下:
[aolens@aolens ~/Documents/python/learning]$ python test.py
[============================= ] 78%
本文出自 “aolens·程超” 博客,转载请与作者联系!
原文地址:http://aolens.blog.51cto.com/7021142/1846446