feat: completed problem-09.py

This commit is contained in:
baphim
2026-09-14 16:22:54 -04:00
parent 523b96b152
commit 968ce1621d
+11 -1
View File
@@ -1 +1,11 @@
# Write a Python program that opens a file and handles a UnicodeDecodeError exception if there is an encoding issue. # Write a Python program that opens a file and handles a UnicodeDecodeError exception if there is an encoding issue.
#Try opening the 'test.bin' file (which was created specifically for this problem) and assign it to 'f'
try:
with open('test.bin') as f:
# Attempt to read the 'test.bin' file
f.read()
# Handle the expected UnicodeDecodeError exception
except UnicodeDecodeError:
# Print the error message
print('There was an encoding problem with this file')