Answers for "check is directory python"

15

how to check in which directory python in running

import os
cwd = os.getcwd()
Posted by: Guest on March-09-2020
0

python os is directory

import os.path
  
# Path
path = '/home/User/Documents/file.txt'
  
# Check whether the 
# specified path is an
# existing directory or not
isdir = os.path.isdir(path)
print(isdir)
  
  
# Path
path = '/home/User/Documents/'
  
# Check whether the 
# specified path is an
# existing directory or not
isdir = os.path.isdir(path)
print(isdir)
Posted by: Guest on March-26-2021
0

check if path is a folder python

import os

# check the if the path is a directory
print(os.path.isdir("path"))

# check if the path is a file
print(os.path.isfile("path"))
Posted by: Guest on August-13-2021

Code answers related to "check is directory python"

Python Answers by Framework

Browse Popular Code Answers by Language