मराठी

Write a try .... except statement that attempts to open a file for reading and catches the exception thrown when the file does not exist.

Advertisements
Advertisements

प्रश्न

Write a try .... except statement that attempts to open a file for reading and catches the exception thrown when the file does not exist.

कोड लेखन
Advertisements

उत्तर

try:
    file = open("data.txt", "r")
except FileNotFoundError:
    print("File does not exist.")
shaalaa.com
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 7: Data File Handling - EXERCISE [पृष्ठ १४५]

APPEARS IN

सीबीएसई Computer Science with Python [English] Class 12
पाठ 7 Data File Handling
EXERCISE | Q 3. | पृष्ठ १४५
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×