常用的目录、文件操作
# 依赖的模块
import os
import shutil
- 删除目录(即,删除文件夹的所有内容)
root_dir = "./landscape"
if os.path.exists(root_dir):
shutil.rmtree(root_dir)
- 创建目录
effect_dir = "effects"
os.makedirs(effect_dir)
- 拷贝文件
src_file = "./template/config.json"
dst_file = root_dir+"/config.json"
shutil.copyfile(src_file,dst_file)