Python open() FunctionPython Functions


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

Example

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

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

Syntax

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

Parameters

The parameters include the required filename and optional open mode.

Return Value

The method doesn’t return any value.

© 2021 Programtips.org, all rights reserved. Privacy Policy | Contact Us