Python os.makedirs() 方法

Python 教程 · 2019-02-04 06:59:25

概述

os.makedirs() 方法用于递归创建目录。像 mkdir(), 但创建的所有intermediate-level文件夹需要包含子目录。

语法

makedirs()方法语法格式如下:

os.makedirs(path, mode=0o777)

参数

  • path -- 需要递归创建的目录。

  • mode -- 权限模式。

返回值

该方法没有返回值。

实例

以下实例演示了 makedirs() 方法的使用:

#!/usr/bin/python
# -*- coding: UTF-8 -*-

import os, sys

# 创建的目录
path = "/tmp/home/monthly/daily"

os.makedirs( path, 0755 );

print "路径被创建"

执行以上程序输出结果为:

路径被创建

点击查看所有 Python 教程 文章: https://codercto.com/courses/l/8.html

查看所有标签

Learning Web Design

Learning Web Design

Jennifer Niederst Robbins / O'Reilly Media / 2007-6-15 / USD 44.99

Since the last edition of this book appeared three years ago, there has been a major climate change with regard to web standards. Designers are no longer using (X)HTML as a design tool, but as a means......一起来看看 《Learning Web Design》 这本书的介绍吧!

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具