SRE
Mastery
Course
Stats
← Back
📁 Files & JSON
Q1/7
+0 XP
💡 Key Concept
▲
with statement ensures file is closed even if error occurs. Context manager.
What is the safe way to read a file?
A
f = open("file"); f.read()
B
with open("file") as f:
C
file.read()
D
read("file")