In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Python programming language how to get directory content and create a directory, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can get something.
How the Python programming language gets the contents of the directory
In Python, you can use the os.listdir () function to get the contents of the specified directory. The prototype is shown below.
Os.listdir (path)
The meaning of the parameters is as follows. Path wants to get the path to the content directory. The following example gets the contents of the current directory.
> import os > > os.listdir (os.getcwd ())
Get the contents of the current directory
['dde.pyd',' license.txt', 'Pythonwin.exe'
'scintilla.dll', 'win32ui.pyd',' win32uiole.pyd'
'pywin']
How to create a directory in Python programming language
You can use the os.mkdir () function to create a directory in Python. The prototype is shown below.
Os.mkdir (path)
The meaning of its parameters is. The path where path wants to create the directory. The following example creates a temp directory under the E:\ book directory.
> import os > os.mkdir ('E:\\ book\\ temp')
Create a directory using os.mkdir
Delete directory
You can use the os.rmdir () function to delete a directory in Python. The prototype is shown below.
Os.rmdir (path)
The meaning of the parameters is as follows. The path to the directory that path wants to delete. The following example deletes the E:\ book\ temp directory.
> import os > os.rmdir ('E:\\ book\\ temp')
To delete a directory, it is important to note that the directory deleted using os.rmdir must be an empty directory, otherwise the function will go wrong.
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.