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

PythonServer Side ProgrammingProgramming

#### Beyond Basic Programming - Intermediate Python

Most Popular

36 Lectures 3 hours

#### Practical Machine Learning using Python

Best Seller

91 Lectures 23.5 hours

#### Practical Data Science using Python

22 Lectures 6 hours

"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.

Updated on 12-Dec-2019 07:02:49