How To Make Directory in Python? – POFTUT

How To Make Directory in Python?

Python provides different functions and libraries for operating system related operations. Creating new directory or directories is very popular thing amongst developers. In this tutorial we will look how to create and make directory in PYthon.

Using OS Library with Mkdirs Function

Python provides os library which is mainly used for Operating system related operations. We will use mkdirs function by providing the directory name. In this example we will create a directory named myfile in the current working directory.

Provide Absolute Path

During a directory creating given file with named will be created in the current working directory. Current working directory is the path where the application or interactive console run. This situations may cause errors some time. We can prevent this errors and use more specific directory and path by providing absolute path.

In this example we will create a directory named myfile3 in the path /home/ismail/

LEARN MORE  How To Compress Files and Folders In File System Level With Compact Command In Windows NTFS?

Leave a Reply

Your email address will not be published. Required fields are marked *

Enjoy this blog? Please spread the word :)