How to Use open() Function in PythonPython Basics

The open() function opens the file and returns a corresponding file object.


# opens test.text file of the current directory
f = open("test.txt")

# full path
f = open("C:/Python3/test.txt")


open(name[, mode[, buffering]])


The parameters include the required filename and optional open mode.

Return Value

The method doesn’t return any value.

© 2024, all rights reserved. Privacy Policy | Contact Us