0
我想要改变一条线上的简单计数器。我有以下几点:如何在Python 2.7中打印当前行?
from __future__ import print_function
from time import sleep
for i in range(400):
print("\r" + str(i), end = "")
sleep(0.5)
在Python 3,它做工精细,用计数器递增在同一行,但在Python 2,没有显示。我怎样才能让它在Python 2中显示?
编辑:我对那两个Python的工作,2和3
作品只是保证(输出unbuffered)[http://stackoverflow.com/questions/107705/disable-output-buffering] – keety