【发布时间】:2017-05-30 15:49:26
【问题描述】:
我要编写的代码非常简单:
我想打印一个迭代变量,但我不想为每个循环打印所有行,我希望它会更新前一个。
例子:
for i in range(0,2000):
print 'number is %d', %i
错误的结果:
number is 0
number is 1
number is 2
number is 3
number is 4
number is 5
number is 6
...
...
我想要的是:
number is 0
在第二次迭代中:
number is 1 `(it will replace 0 and I don't want the previous 0 anymore).`
这将类似于仅在一行中更新某些内容的百分比。
在 Python 中是否存在用于它的函数?
【问题讨论】:
-
仅供参考:您使用 # 在 python 中编写 cmets
标签: python