Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- def new_directory(directory, filename):
- # Before creating a new directory, check to see if it already exists
- if not os.path.exists(directory):
- os.mkdir(directory)
- os.chdir(directory)
- # Create the new file inside of the new directory
- file = open(filename, "x")
- file.close()
- # Return the list of files in the new directory
- return os.listdir()
- print(new_directory("PythonPrograms", "script.py"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement