Home >Backend Development >Python Tutorial >Basic steps to create a folder in python

Basic steps to create a folder in python

爱喝马黛茶的安东尼
爱喝马黛茶的安东尼Original
2019-06-14 17:51:317951browse

How to create a folder in python?

Related recommendations: "python Video"

Basic steps to create a folder in python

##The steps are as follows:

First You can use exists in Python's os module to determine whether the directory exists.

Basic steps to create a folder in python

#If the directory or file exists, os will return a TRUE result.

Basic steps to create a folder in python

#To create a directory, you can first use getcwd to obtain the current directory and then splice the directory name to create the folder.

Basic steps to create a folder in python

The mkdir in Python's os module can also directly use the absolute path to create an empty folder.

Basic steps to create a folder in python

If you want to create a multi-level directory, you need to use makedirs in the os module.

Basic steps to create a folder in python

The above is the detailed content of Basic steps to create a folder in python. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn