In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "what are the common modules of Python". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let Xiaobian take you to learn "What are the common modules of Python"!
What can Python do?
If the development is divided according to the hierarchy, it can be divided into system development (mainly some systematic functions, such as network services, file services, system calls, etc.); business logic development (mainly some business logic, such as billing, finance, permissions, etc., which have little to do with the operating system or the underlying layer). Python, both in system development and business development, can well meet the needs of developers and help developers successfully complete tasks, which not only benefits from the characteristics of Python itself, but also depends on a wealth of official and third-party module libraries.
Common Python modules
webpy module, with which you can implement a web server in just a few lines of code
SocketServer module, with which you can easily develop your own tcp, udp server
subprocess module, which allows you to create and manage processes
threading module, which allows you to create and manage multithreads
queue module is a thread-safe queue
json module, this one is used to process json data
logging module, this is a logging module
shutil module, this is a file management module, contains the basic file operations
urllib module, is a commonly used http module
There are many standard and non-standard modules, only you can not imagine
In order to better manage python modules, python also has specialized module management tools, such as centos yum can find, install the required modules, python package management tools are the most common ip, about finding, installing, using modules, we will be in the future python series articles.
What does Python do?
A lot of partners will ask, what big projects can Python do? Any practical examples?
Naturally, the following are well-known projects written in Python:
BitTorrent, well-known BT download software
OpenStack Open Source Cloud Platform Framework
Yum, CentOS package management tool
A large number of Google internal and external services are developed using Python, such as gmail, earth, maps, etc.
Douban, a well-known community in China, python is the main development language of Douban, etc.
Is the restless heart a little more quiet? Ha ha!
Why learn Python?
After reading the above two points, I don't think it's enough to impress everyone to learn python. Here's why we should learn python and who applies python?
Life is short and I use Python.
Here's what we've been talking about, if you're a developer with a wife and kids.(Your wife is very beautiful, your children are very cute, this is very important, and then remember that you are a wife, children of people), Friday is coming off work, you asked your wife and children to go to a restaurant that is difficult to make reservations, suddenly received the boss's task, you have to do a Mini programs, probably the function is to scan the server under the specified directory (There are subdirectories below this directory), and check whether the first 1KB of the file contains certain keywords, and delete the file if it does. The boss said it was urgent because the server disk was bursting and files had to be deleted, but it was less than 30 minutes before work ended.
As a c, c++ developer, you have to consider whether to use recursion or non-recursion to enumerate the files below the folder. After enumerating, you have to allocate a memory to read the 1KB content at the beginning of the file, and also study the string matching algorithm. Don't forget, after finishing, you have to release the memory and close the file handle. As a result, it took a lot of time to conceive before writing. After writing, it took a lot of time to debug. It also does not include whether there are bugs that cause the program to crash such as memory boundaries. As a result, he had to work overtime and couldn't accompany his wife and children to dinner.
As a java developer, you are happy, less c, c++ memory leakage, forget to close the handle of the trouble, but you also need to think about how many of these things can be abstracted into classes, interface design, find java has no ready-made package can be used, and then toss about compiling java projects, and then debugging, the results you may only need to work overtime a little time to catch up with his wife and children to eat.
As a Python developer, I know that enumerating files in a folder directory can use the listdir function in the os module to return a list list, open the file with open and then read the data directly, and use the string find function to find whether there is a matching keyword. Don't forget that Python also has a with function. After I have opened the file, I don't have to worry about the exception behind and whether to close the file handle. With will help me wipe my ass. Finally, I can call the remove function of the os module to delete the file. In the end, the python developer finished the task on time, ate dinner with his wife and children, and got praise from his boss.
The above is purely YY, but from such a YY story can reflect a phenomenon, many things, we can use the relatively simple and fast python to complete the task, there is no need to use c, c++ these languages at every turn. Life time is very precious, should waste time on good things above, python has a lot of ready-made official, third-party libraries, are usually extracted in the work, are highly reusable and very stable, coupled with python's own characteristics can avoid some bad places such as c, c++, such as containers, string operations, etc., easy to leak, cross the problem. Finally, this story does not mean black c, c++, java language, each language has its own good place, but we should learn more convenient language, to solve some small problems, small things, limited energy spent on important places.
Python can complete both large projects and small tasks, so both developers and operation and maintenance personnel can use Python to solve large and small problems in their work. At the same time, many APIs or libraries support Python very well, especially some libraries written in Python themselves, which natively support Python interfaces.
At this point, I believe that everyone has a deeper understanding of "what are the common modules of Python", so let's actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!
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.