开发者

printing to the screen on the same line at different times

My code looks like this:

print "Doing Something...",
do_some_function_that_takes_a_long_time()
print "Done"

I want it to print that statement at the top to the screen first, then do the function, and then print the "Done" line. Currently开发者_运维问答 it waits until the "Done" line is executed before it prints the top part with it.

In other words, I want the pausing to occur with "Doing Something..." on the screen. How do I achieve this?


You have to flush the output after your first print.


You can also do something like: http://www.mutaku.com/wp/index.php/2011/06/python-dynamically-printing-to-single-line-of-stdout/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜