9 lines
372 B
Python
9 lines
372 B
Python
# Write a Python program that opens a file and handles a PermissionError exception if there is a permission issue.
|
|
# Try opening 'filename2.txt' (file created with 000 permissions as to trigger exception
|
|
try:
|
|
open('filename2.txt')
|
|
# Handle expected PermissionError exception
|
|
except PermissionError:
|
|
# Print error message
|
|
print('Insufficient file permissions')
|