废话不多说,直接贴出源码
year = "2012" month = "10" day = "31" path = "D:\\Env\\bair\\" title_year = str(year) title_month = str(month) title_day = str(day) new_path_year = os.path.join(path,title_year) if not os.path.isdir(new_path_year): os.makedirs(new_path_year) new_path_month = os.path.join(new_path_year,title_month) if not os.path.isdir(new_path_month): os.makedirs(new_path_month) new_path_day = os.path.join(new_path_month,title_day) if not os.path.isdir(new_path_day): os.makedirs(new_path_day)