import os


# 创建多级文件(不含文件)
def create_dir(file_path):
    if os.path.exists(file_path) is False:
        os.makedirs(file_path)


if __name__ == '__main__':
    # 创建绝对路径文件(硬盘)
    create_dir('D:/aaa')
    with open('D:/aaa/a.txt', 'w', encoding='utf-8') as f:
        f.write('七夕节')
    # 创建相对路径文件(项目根目录)
    with open('a.txt', 'w', encoding='utf-8') as f:
        f.write('七夕节')