Python open() Function
The open() function opens a file, and returns it as a file object.
Syntax
open(file, mode)
Parameters
| Parameter | Description |
|---|---|
file |
Required. The path and name of the file |
mode |
Optional. A string, defined which mode you want to open the file
in:
|
Return Value
A file object.
Example
Using the open() function:
Output
Click Run to execute your code
Enjoying these tutorials?