[Python] os.mkdir() V.S. os.makedirs()

os.mkdir()只會建一層目錄,如果中間不存在就會丟exception

os.makedirs()會把中間的目錄也建起來

Example(假設folderA and folderB都不存在)

os.mkdir(“./folderA”) -> OK
os.makedirs(“./folderA”) -> OK
os.mkdir(“./folderA/folderB”) -> NOT OK ,除非folderA存在
os.makedirs(“./folderA/folderB”) -> OK

http://stackoverflow.com/questions/13819496/what-is-different-between-makedirs-and-mkdir-of-os

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.