##language:zh #pragma section-numbers off ##含有章节索引导航的 ZPyUG 文章通用模板 <> ## 默许导航,请保留 <> = 命令行进度条 = ##startInc == 需求 == {{{ Rodgers reply-to python-cn@googlegroups.com to python-cn`CPyUG`华蟒用户组 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%') }}} 参考:[[http://topic.csdn.net/u/20070403/18/bba2c9a8-9a81-4bbc-a4b9-305e91d7e2cd.html|写了一个console程序,但是想在同一行(同一位置)刷新显示的内容]] ##endInc ---- 创建 by -- ZoomQuiet [<>] == 反馈 ==