feat: completed problem-09.py
This commit is contained in:
+11
-1
@@ -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')
|
||||
Reference in New Issue
Block a user