Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
+2 votes
9 views
in Python by (46k points)
I want to output to the screen using print function in Python, How can I do it?

2 Answers

0 votes
by (2k points)
edited by

Just use this:

import sys
sys.stdout.flush()

Cheers..!! 

0 votes
by (106k points)
edited by

For Python version 3 or higher, you can just provide flush=True as a keyword argument to the print function:

print('foo', flush=True)

For Python 2,  you can just call file.flush() with the print statement:-

import sys 

print('delayed output')

sys.stdout.flush()

You can use the following video tutorials to clear all your doubts:-

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Sep 23, 2019 in Python by Sammy (47.6k points)
0 votes
4 answers
+1 vote
2 answers

Browse Categories

...