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

乌拉乌拉~
Release: 2018-08-17 17:54:19
Original
4567 people have browsed it

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")
Copy after login

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")
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!