मराठी

What is the advantage of using with clause while opening a data file in Python? Also give syntax of with clause. - Computer Science (Python)

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
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
2023-2024 (February) Set 4
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×