# This requires Python’s OS module import os # 'mkdir' creates a directory in current directory. os.mkdir('tempDir') # can also be used with a path, if the other folders exist. os.mkdir('tempDir2/temp2/temp') # 'makedirs' creates a directory with it's path, if applicable. os.makedirs('tempDir2/temp2/temp')
Here is what the above code is Doing:
1. It creates a directory named ‘tempDir’ in the current directory.
2. It creates a directory named ‘tempDir2’ in the current directory.
3. It creates a directory named ‘temp2’ in the directory ‘tempDir2’.
4. It creates a directory named ‘temp’ in the directory ‘tempDir2/temp2’.