Python open() Function
Open a file and print the content:
f = open("demofile.txt", "r")
Try it Yourself »
Definition and Usage
open() function opens a file, and
returns it as a file object.
Read more about file handling in our chapters about File Handling.
|The path and name of the file
|A string, define which mode you want to open the file in:
In addition you can specify if the file should be handled as binary or text mode
Learn how to open files in our Read Files Tutorial
Learn how to write/create files in our Write/Create Files Tutorial
Learn how to delete files in our Delete Files Tutorial