首页 > 技术文章 > Python使用日常

lpworkstudyspace1992 2017-10-27 17:46 原文

#Python中文件夹和文件的判断
import
os My_Path = "/home/lpworkstudy/Gooddir/" #现在我们判断这个文件夹是否存在 #如果不存在,我们就创建 if not os.path.isdir(My_Path): os.makedirs(My_Path) #创建多级目录 os.path.exists() #判断文件是否存在

 

推荐阅读