Answers for "how to check a path exists in python"

27

python check if path does not exist

import os
if not os.path.exists('my_folder'):
    os.makedirs('my_folder')
Posted by: Guest on April-10-2020
9

file exist python

import os.path

if os.path.exists('filename.txt'):
    print ("File exist")
else:
    print ("File not exist")
Posted by: Guest on May-13-2020
1

pathlib path exists

import pathlib
path = pathlib.Path('my/path/to/file/or/dir')
assert path.exists()
Posted by: Guest on August-27-2021
6

how to check if file exists pyuthon

import os
file_exists = os.path.exists("example.txt") # Returns boolean representing whether or not the file exists
Posted by: Guest on September-15-2020

Code answers related to "how to check a path exists in python"

Python Answers by Framework

Browse Popular Code Answers by Language