-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdirectory.py
More file actions
23 lines (19 loc) · 771 Bytes
/
Copy pathdirectory.py
File metadata and controls
23 lines (19 loc) · 771 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import os
def list_directory_contents(directory):
try:
# Get the list of entries in the directory
entries = os.listdir(directory)
# Print each entry
print(f"Contents of directory '{directory}':")
for entry in entries:
print(entry)
except FileNotFoundError:
print(f"Error: The directory '{directory}' does not exist.")
except PermissionError:
print(f"Error: Permission denied to access the directory '{directory}'.")
except Exception as e:
print(f"An unexpected error occurred: {e}")
# Specify the directory path
directory_path = '/MinGW' # '.' refers to the current directory
# List the contents of the specified directory
list_directory_contents(directory_path)