Home  »  CodeSnippets   »   How to Read a File in Python

How to Read a File in Python

Posted: February 6, 2022 | by Site Host

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.

Share it!

See also  How to Rotate HTML Element 90 Degrees Using CSS