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/
精彩评论