
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Catch Exception While Using Python with Statement
The code can be rewritten to catch the exception as follows:
try: with open("myFile.txt") as f: print(f.readlines()) except: print('No such file or directory')
We get the following output
C:/Users/TutorialsPoint1/~.py No such file or directory
Advertisements