To create a folder and navigate to it in Python, you can use the os
module.
Here's the code to achieve this:
main.py269 chars15 lines
The os.mkdir(folder_name)
function creates a folder with the specified name. The os.chdir(folder_name)
function changes the working directory to the newly created folder. Finally, os.getcwd()
returns the current directory path, which should be the path to the created folder.
Make sure to import the os
module at the beginning of your code.
gistlibby LogSnag