Python output alternatives

Are there any alternatives to the print statement for output in Python.
Also, how can I format the output text for color coding?

I am a beginner programmer, new to this.
Thanks

+3
source share
2 answers
sys.stdout.write()

This is one of the alternatives. You can also write sys.stderr. Personally, I use sys.stdoutit when I need to pass a common "stream" to some function that will write to it. And the open file is the stream, and the sys.stdoutstream. Thus, my function can be parameterized for writing, either for output or for a file.

sys.stdout.write , print , print , .

, . SO.

+9
0

Source: https://habr.com/ru/post/1739667/


All Articles