পাইথনে এক্সসেপশন হ্যান্ডল করার সবচেয়ে সহজ পদ্ধতি হলো "try-except" ব্লক ব্যবহার করা।
উদাহরণ
try:
fob = open("test.txt", "r")
fob.write("This is my test file for exception handling!!")
except IOError:
print("Error: can't find the file or read data")
else:
print("Write operation is performed successfully on the file")
fob.close()
আউটপুট
Error: can't find the file or read data