sys模块 进度条百分比

用于提供对Python解释器相关的操作:

1 sys.argv           命令行参数List,第一个元素是程序本身路径
2 sys.exit(n)        退出程序,正常退出时exit(0)
3 sys.version        获取Python解释程序的版本信息
4 sys.maxint         最大的Int值
5 sys.path           返回模块的搜索路径,初始化时使用PYTHONPATH环境变量的值
6 sys.platform       返回操作系统平台名称
7 sys.stdin          输入相关
8 sys.stdout         输出相关
9 sys.stderror       错误相关

进度条百分比

1 #!/usr/bin/env python
2 import sys
3 import time
4 for i in range(101):
5     sys.stdout.write('
')
6     sys.stdout.write("%s%% |%s" % (int(i/100*100),int(i)*"*"))
7     sys.stdout.flush()#刷新
8     time.sleep(0.1)
原文地址:https://www.cnblogs.com/shiluoliming/p/6395302.html