Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Check if a Directory is empty and also check exceptional situations.
- import os
- path = "C:\\Users\\Hamed\\Desktop"
- if os.path.exists(path) and os.path.isdir(path):
- if not os.listdir(path):
- print("Directory is empty")
- else:
- print("Directory is not empty")
- else:
- print("Given Directory don't exists")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement