python 创建新文件夹

时间:2023-01-19 18:11:06
import os
def create_foleder(foldernames):
current_position="E:/"
foldername=str(current_position)+str(foldernames)+"/"
isCreated=os.path.exists(foldernames)
if not isCreated:
os.makedirs(foldernames)
print(str(foldernames)+'is created')
return True
else:
print("the folder has been created before")
return False
#在e盘创建文件夹,输入文件夹名字,在e盘创建,如果已经存在就输出已存在