with open() | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

with open()

Can someone explain why "with open("myfile.txt", "r") as f:" has indentation and what the indentations can be used for?

2nd Jul 2017, 12:01 PM
Daan van IJcken
Daan van IJcken - avatar
1 ответ
+ 2
To explicit where end use of 'with' statement, wich create a new scope... ending the scope will implicitly close the file...
2nd Jul 2017, 12:53 PM
visph
visph - avatar