# What does "print >>" do in python?

PythonServer Side ProgrammingProgramming

"print >>" is a syntax to extend the standard 'print' statement so that it can be used to print to any file-like object, instead of the default sys.stdout. So it can be used to print directly to files.

## Example

For example, you open a file called my_file, then you can write to it using:

 >>> my_file =open("my_file")
>>> print >>my_file, "Hello World"

This will write "HelloWorld" to my_file. It can also be used with other file like objects.

Published on 21-Dec-2017 13:18:50