python自动刷新网页_控制台进度自动刷新python方法源码

要实现控制台的监控,达到能完成控制台进度自动刷新python方法源码。这是我自己测试用的,能达到我预期的要求,应该还能再精进一些。有需要类似操作的朋友可以自己再把代码改一下再用。

下边的python方法中,只需要用python sys和python time时间模块中的方法,还是比较简单的。

import sys

import time

# Output example: [======= ] 75%

# width defines bar width

# percent defines current percentage

def progress(width, percent):

print "%s %d%%\r" % (('%%-%ds' % width) % (width * percent / 100 * '='), percent),

if percent >= 100:

print

sys.stdout.flush()

# Simulate doing something ...

for i in xrange(100):

progress(50, (i + 1))

time.sleep(0.01) # Slow it down for demo

#www.iplaypy.com

玩蛇网文章,转载请注明出处和文章网址:https://www.iplaypy.com/code/scripts-shell/ss2342.html

相关文章 Recommend

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值