Answers for "os.mkdir python"

3

python mkdir

if not os.path.exists(path):
  os.mkdir(path)
Posted by: Guest on July-18-2021
0

os.mkdir exceptions

import os
import errno
if not os.path.exists(value):
    try:
        os.makedirs(value, 0o700)
    except OSError as e:
        if e.errno != errno.EEXIST:
            raise
Posted by: Guest on November-14-2020
2

os module in python

# Delete everything reachable from the directory named in "top",
# assuming there are no symbolic links.
# CAUTION:  This is dangerous!  For example, if top == '/', it
# could delete all your disk files.
import os
for root, dirs, files in os.walk(top, topdown=False):
    for name in files:
        os.remove(os.path.join(root, name))
    for name in dirs:
        os.rmdir(os.path.join(root, name))
Posted by: Guest on December-25-2020

Python Answers by Framework

Browse Popular Code Answers by Language