+2 votes
2 views
in Python by (46.1k 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 (107k 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
asked Sep 23, 2019 in Python by Sammy (47.8k points)
+1 vote
2 answers
0 votes
2 answers
0 votes
1 answer
asked Sep 23, 2019 in Python by Sammy (47.8k points)
0 votes
1 answer
asked Sep 23, 2019 in Python by Sammy (47.8k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...