Home  >  Article  >  Backend Development  >  What is the python directory? How to create a directory?

What is the python directory? How to create a directory?

乌拉乌拉~
乌拉乌拉~Original
2018-08-17 17:54:194681browse

In today's article, we will learn about one aspect of directories in python. First of all, in this article, we will learn about How to create a directory in python. Only by learning how to create a directory first can we proceed to the next step. In this article, I will explain how to modify the python directory.

Directories

All files are contained in different directories, but Python can also handle them easily. The os module has many methods to help you create, delete and change directories.

mkdir() method

You can use the mkdir() method of the os module to create new directories in the current directory. You need to provide a parameter containing the name of the directory to be created.

Syntax:

os.mkdir("newdir")

Example:

The following example will create a new directory test in the current directory.

# !/usr/bin/python
# -*- coding: UTF-8 -*-
import os
# 创建目录test
os.mkdir("test")

The above is all about how to create a directory in Python directory in this article. I hope what I said and the examples I gave can be helpful to you.

For more related knowledge, please visit the Python tutorial column on the php Chinese website.

The above is the detailed content of What is the python directory? How to create a directory?. 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

Related articles

See more