In Python, OS libraries are often used to operate files. How to create a directory structure that does not exist
Determine whether the directory exists. If it does not exist, create a new one:
import os if not os.path.isdir(dir_name): os.makedirs(dir_name)
os.mkdir() creates the last-level directory in the path. If the previous directory does not exist and needs to be created, an error will be reported.
os.makedirs() creates multi-level directories. If the intermediate directories do not exist, they will be created automatically.
The above is the detailed content of How to create a directory structure that does not exist. For more information, please follow other related articles on the PHP Chinese website!