命令行进度条

需求

Rodgers <peninsula1103@gmail.com>
reply-to        python-cn@googlegroups.com
to      python-cn`CPyUG`华蟒用户组 <python-cn@googlegroups.com>
date    Tue, Jan 12, 2010 at 22:40
subject [CPyUG:114725] 想显示一个数字,然后让它不断变化应该怎么做

就像有时候命令行下安装程序,显示"installing 1%",然后那个1就不断变化,应该怎么做?不能每次把所有的输出全部清掉再显示新的

解决

print "1%",
print "\b\b\b2%"

or

sys.stdout.write('installing 1%')
sys.stdout.write('\b'*20+'installing 2%')

参考:写了一个console程序,但是想在同一行(同一位置)刷新显示的内容


创建 by -- ZoomQuiet [2010-01-13 02:31:27]

反馈

MiscItems/2010-01-13 (last edited 2010-01-13 02:31:27 by ZoomQuiet)