Python file detection handling tutorial example explained
#python #file #handling
import os
path = "C:\\Users\\User\\Desktop\\test.txt"
if os.path.exists(path):
print("That location exists!")
if os.path.isfile(path):
print("That is a file")
elif os.path.isdir(path):
print("That is a directory!")
else:
print("That location doesn't exist!")
#python #file #handling
import os
path = "C:\\Users\\User\\Desktop\\test.txt"
if os.path.exists(path):
print("That location exists!")
if os.path.isfile(path):
print("That is a file")
elif os.path.isdir(path):
print("That is a directory!")
else:
print("That location doesn't exist!")
- Category
- Bro Code
- Tags
- python file handling, python file detection, file handling python

Be the first to comment