Create a new directory

import os path = "C:/Users/myuser/secrets/" # If the directory doesn't exist... if not os.path.exists(path): # create it! os.makedirs(path)
Create a directory using the Operating System module if the directory doesn't already exist.

1 Response

You know, you could use the 'try' and 'except' instead of an if statement, that way you could send a message like "This already exists".

Write a comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.