How to Open File in Python


In this example we will show how to open the file in Python.

Source Code

f = open('myfile.txt', 'r', encoding='utf-8')
text = f.read()
print(text)

Output:

Hello World!
Python is a programming language that lets you work more quickly and integrate your systems more effectively.
I love Python!
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments