# Python file detection
import os
file_path = "test.txt"
if os.path.exists(file_path):
print(f"The location '{file_path}' exists")
if os.path.isfile(file_path):
print("That is a file")
elif os.path.isdir(file_path):
print("That is a directory")
else:
print("That location doesn't exist")
#pythontutorial #python #pythonprogramming
import os
file_path = "test.txt"
if os.path.exists(file_path):
print(f"The location '{file_path}' exists")
if os.path.isfile(file_path):
print("That is a file")
elif os.path.isdir(file_path):
print("That is a directory")
else:
print("That location doesn't exist")
#pythontutorial #python #pythonprogramming
- Category
- Bro Code
- Tags
- Python tutorial, python course, python programming
Be the first to comment



