python mkdir to make folder with subfolder?

b7875787 picture b7875787 · Jul 14, 2011 · Viewed 63.1k times · Source

This works:

mkdir('folder')

but this doesn't

mkdir('folder/subfolder')

error:

WindowsError: [Error 3] The system cannot find the path specified: 'folder/subfolder'

Answer

Matthew Iselin picture Matthew Iselin · Jul 14, 2011

Try os.makedirs instead, if you want to create a tree of directories in one call.