Print without newline under function doesn't work as it should in Python -
i'm doing progressbar uploading script , therefor want print row of multiple '#' can't work. when tell python not add newline remove doesn't work expected under functions. using "print ('#', end='')" in python 3 or "print '#'," in python 2 removes when executed under functions doesn't print out until whole function finished, should not wait normal print.
import time = 0 def status(): print('#', end='') while < 60: status() time.sleep(1) += 1
this should print '#' every second doesn't. prints them after 60 seconds. using print('#') prints out every second expected. need fix this. please help!
solution: "sys.stdout.flush()" after each print :)
you need flush output buffer after each print
invocation. see how flush output of python print?
Comments
Post a Comment