This article mainly introduces how to use third-party libraries.
1. Understand third-party libraries
Python is equivalent to a mobile phone, and third-party libraries are equivalent to various apps in the mobile phone.
When we want to build a website, we can choose web frameworks such as full-featured Django and lightweight Flask; when we want to be a crawler, we can use the Scrapy framework; when we want to do data analysis, we can choose the Pandas data framework, etc. These are some very mature third-party libraries.
So, how do you find the corresponding library according to your needs?
You can find the required libraries by category on https://awesome-python.com.
2. Install third-party libraries
Here we mainly introduce how to install third-party libraries in PyCharm.
1 ) Open PyCharm-top menu File-select Default Settings;
2 ) Search project interpreter, select the current Python environment, and then click the "+" sign at the bottom to add a library;
3 ) Search the database name-select the library and click Install Package at the bottom. After the installation is successful, a successful prompt will appear. At this time, you can return to the previous Project Interpreter to view the library you installed. Click the "-" sign to uninstall it. The required library.
3. Use third-party libraries
When using a third-party library, you can use it as long as you enter the library in PyCharm. Use import for the input library. For example, input the requests library as: import requests.
The basic knowledge about Python in the first stage is roughly here, and the sharing in the second stage will be mainly on Python crawlers.
Knowledge point supplement:
Examples of library usage:
jieba library
Installation: pip install jieba
Chinese word segmentation
Use a Chinese thesaurus to determine the correlation probability between Chinese characters
Chinese characters are formed into phrases with high probability to form word segmentation results. In addition to word segmentation, users can also add custom phrases (such as names or proper nouns such as Sima Xiangru, etc.)
Three modes
jieba.lcut(s) precise mode, returns a list type word segmentation result
jieba.lcut("China is a great country")
[' China','is','one','great','of','country']
This is the end of this article about learning to use libraries for python novices. For more relevant python how to use the library, please search the previous articles of ZaLou.Cn or continue to browse the related articles below. Hope you will support ZaLou.Cn more in the future!
Recommended Posts