Why python print is delayed?
问题 I am trying to download file using requests, and print a dot every time retrieve 100k size of file, but all the dots is printed out at the end. See code. with open(file_name,'wb') as file: print("begin downloading, please wait...") respond_file = requests.get(file_url,stream=True) size = len(respond_file.content)//1000000 #the next line will not be printed until file is downloaded print("the file size is "+ str(size) +"MB") for chunk in respond_file.iter_content(102400): file.write(chunk)