一言不合就上代码,哈哈,由于比较简单就不解释了。
import os
MESSAGE = 'The directory already exists.'
TESTDIR = 'testdir'
try:
path = os.path.abspath("c:\Windows")
print(path)
if not os.path.exists(os.path.join(path, TESTDIR)):
os.makedirs(os.path.join(path, TESTDIR))
else:
print(MESSAGE)
except Exception as e:
print(e)
网友评论