Advertisements
Advertisements
प्रश्न
What is the advantage of using with
clause while opening a data file in Python? Also give syntax of with
clause.
लघु उत्तरीय
उत्तर
In Python, when a file is opened using the with clause, the with code block's flow of execution guarantees that open file descriptors are automatically closed.
Syntax:
with open(filename, opening-mode) as fileobject:
Operations on file...
shaalaa.com
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?