参考链接:https://blog.csdn.net/weixin_43826242/article/details/87101436
创建目录结构
# 创建文件目录结构 def create_folder(folder_name): result_data = 0 folder_name_exist = os.path.exists(folder_name) if not folder_name_exist: os.makedirs(folder_name) if not os.path.exists(folder_name): result_data = 1 return result_data
删除文件夹(文件夹里面有文件的情况)
def delete_folder(path): for i in os.listdir(path): path_file = os.path.join(path, i) if os.path.isfile(path_file): os.remove(path_file) else: delete_folder(path_file) os.removedirs(path)
ok.