Problem Statement
What is the recommended way to avoid encoding issues when opening text files?
Explanation
Defaults vary by system and locale. Declaring UTF eight makes behavior predictable across machines and containers.
It also avoids subtle bugs with special characters, especially when moving code between Windows, Mac, and Linux.
Code Solution
SolutionRead Only
with open('notes.txt','r',encoding='utf-8') as f:
txt=f.read()