import os
xxxxxxxxxx
newpath = r'C:\Program Files\arbitrary'
if not os.path.exists(newpath):
os.makedirs(newpath)
xxxxxxxxxx
newpath = r'C:\Program Files\arbitrary'
if not os.path.exists(newpath):
os.makedirs(newpath)
xxxxxxxxxx
newpath = 'C:\Program Files\arbitrary'
if not os.path.exists(newpath):
os.makedirs(newpath)
xxxxxxxxxx
import os
# define the name of the directory to be created
path = "/tmp/year"
try:
os.mkdir(path)
except OSError:
print ("Creation of the directory %s failed" % path)
else:
print ("Successfully created the directory %s " % path)
xxxxxxxxxx
import os
# define the name of the directory to be created
path = "/tmp/year"
try:
os.mkdir(path)
except OSError:
print ("Creation of the directory %s failed" % path)
else:
print ("Successfully created the directory %s " % path)
xxxxxxxxxx
from pathlib import Path
Path("/my/directory").mkdir(parents=True, exist_ok=True)
xxxxxxxxxx
import os
path = 'c:/'
os.chdir(path)
NF = 'file/'
def doesFileExists(filePathAndName):
return os.path.exists(filePathAndName)
if doesFileExists('c:/file'):
pass
else:
path = 'c:/'
os.chdir(path)
NF = 'file'
os.makedirs(NF)