Home  »  CodeSnippets   »   How to Read a File in Python

How to Read a File in Python

Posted: February 6, 2022 | by Michael Bright

f = open('filename.txt', 'r')

Open function is used to open the file. The first parameter is the file to open and the second parameter (r) opens the file in read-only mode.

Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.