07 os.makedirs 创建目录和子目录
os.makedirs 创建目录和子目录
import os
file_path = r'db\xx\xo\xxxxx.txt'
file_folder = os.path.dirname(file_path)
if not os.path.exists(file_folder):
os.makedirs(file_folder)
with open(file_path,mode='w',encoding='utf-8') as f:
f.write('asdf')