Why do I like it Python

For beginners , This is an easy to learn programming language ; Another reason : A large number of out of the box third-party libraries , Exactly 23 10000 software packages provided by users Python Really powerful and popular .

In this paper , I chose 15 One of the most useful software packages , Introduce their functions and characteristics .

1. Dash

Dash It is a relatively new software package , It is made of pure Python Build data visualization app Ideal for , Therefore, it is particularly suitable for anyone who processes data .Dash yes Flask,Plotly.js and React.js Mixture of .

2. Pygame

Pygame yes SDL Multimedia Library Python Decorator ,SDL(Simple DirectMedia Layer) Is a cross platform development library , Designed to provide a low-level interface to :

audio frequency , keyboard , mouse , Joystick, etc .

Pygame High portability , It can run on almost all platforms and operating systems . Although it has a perfect game engine , But you can also use this library directly from Python Script playback MP3 file

3. Pillow

Pillow Dedicated to image processing , You can use this library to create thumbnails , Convert between file formats , rotate , Application filter , Display images, etc . If you need to perform batch operations on many images , This is the ideal choice .

In order to understand it quickly , Look at the following code example ( Load and render ):

4. Colorama

Colorama Allows you to use colors on the terminal , Very suitable Python script , The document is short and interesting , Can be in Colorama PyPI Found on page .

5. JmesPath

stay Python In use JSON Very easy. , because JSON stay Python The mapping on the dictionary is very good . in addition ,Python With their own excellent json library , For parsing and creating JSON. To me , This is one of its best features . If I need to use JSON, May consider using Python.

JMESPath send Python handle JSON Easier , It allows you to explicitly specify how to JSON Extract elements from document . Here are some basic examples , It can let you know its function :

6. Requests

Requests Built on the world's largest number of Downloads Python library urllib3 upper , It makes Web The request becomes very simple , Powerful and versatile .

The following code example illustrates requests How easy it is to use .

Requests You can do all the advanced work you can think of , for example :

*
authentication

*
use cookie

*
implement POST,PUT,DELETE etc.

*
Use custom certificate

*
Use session Session

*
Use agent

7. Simplejson

Python Local in json What's wrong with the module ? No, ! actually ,Python of json yes simplejson. intend ,Python Adopted simplejson A version of , And incorporate it into each distribution . But use simplejson It has some advantages :

It applies to more Python edition .

Its ratio Python The attached version is updated more frequently .

It's very useful C Written ( Optional ) part , So very fast .

Because of these facts , You often use JSON See the following in your script :

 

I will only use the default json, Unless you need it :

speed

Simplejson than json Much faster , Because it uses C Implement some key parts . Unless you're dealing with millions JSON file , Otherwise you won't be interested in this speed .

8. Emoji

Emoji The library is very interesting , But not everyone likes facial expression bags , When analyzing media data ,Emoji The package is very useful .

Here is a simple code example :

9. Chardet

You can use chardet Module to detect the character set of a file or data stream . for example , This is useful when analyzing large amounts of random text . however , When you don't know what the character set is , It can also be used when processing data downloaded remotely .

10. Python-dateutil

python-dateutil The module provides an overview of the standard datetime Powerful expansion of modules . My experience is , Conventional Python Where does the date time function end , and python-dateutil Just appeared .

You can do many great things with this library . I limit these examples to those I find particularly useful : Date in fuzzy analysis log file , for example :

For more features , See full documentation , for example :

Calculate relative increment ( next month , next year , Next monday , The last week of the month, etc ) And the relative increment between two given date objects .

use iCalendar Canonical superset , Calculate date based on repetition rule .

tzfile file (/ etc / localtime,/ usr / share /
zoneinfo etc. ) Time zone (tzinfo) realization ,TZ Environment string ( All known formats ),iCalendar Format file , Given range ( With the help of relative increment ), local computer
time zone , Fixed offset time zone ,UTC Time zone and based on Windows Time zone of the registry .

Internal latest world time zone information based on Olsen database .

use Western,Orthodox or Julian The algorithm calculates the Easter Sunday date of any year .

11. progress bar :progress and tqdm

There's a bit of cheating here , Because these are two bags , But it's unfair to ignore one of them .

You can create your own progress bar , This may be interesting , But use progress or tqdm Package faster , Less error prone .

*
progress

With this package , You can easily create a progress bar :

*
tqdm

tqdm Roughly the same function , But it seems to be the latest . First with gif Some demonstrations in the form of animation :

12. IPython

I'm sure you know Python Interactive shell for , This is running Python A good way to . But you also know IPython
shell Do you ? If you often use interactive shell , But you don't understand IPython, You should check it !

Enhanced IPython shell Some of the features provided include :

*
Comprehensive object introspection .

*
Input history , Cross session persistence .

*
Cache output results during sessions with automatically generated references .

*
Tabulation completion , Supported by default python Variables and keywords , Completion of file name and function keywords .

*
“ Magic ” command , Used to control the environment and perform many tasks related to IPython Or operating system related tasks .

*
Session logging and reloading .

*
yes pdb Debugger and Python Integrated access to analyzer .

*
IPython A little-known function of : Its architecture also allows parallel and distributed computing .

IPython yes Jupyter Notebook Core of , It is an open source Web application program , Allows you to create and share code that contains real-time code , equation , Visualization and narrative text documents .

13. Homeassistant

I like home automation . It's a hobby for me , But I still apologize for that , Because it now controls most of our houses . I use Home
Assistant Tie all the systems in the house together . Although it is indeed a complete application , However, you can also install it as Python PyPI software package .

Most of our lamps are automated , So are the shutters .

I monitor our natural gas consumption , Electricity consumption and output ( Solar panel ).

I can track the location of most phones , And start operation when entering an area , For example, turn on the garage light when I go home .

It can also control all our entertainment systems , For example, Samsung TV and Sonos speaker .

It can automatically discover most devices on the network , So it's very easy to get started .

I have used it every day Home
Assistant already existing 3 Years , It is still in the testing stage , But this is the best platform I've ever tried . It can integrate and control various devices and protocols , And they are free and open source .

If you are interested in automating the house , Please make sure you have the opportunity ! If you want to know more , Please visit their official website . if possible , Please install it on Raspberry
Pi upper . up to now , This is the simplest , The safest way to get started . I installed it in Docker On a more powerful server in the container .

14. Flask

Flask It's my entry library , For creating fast Web Service or simple website . This is a micro framework , That means Flask Designed to keep the core simple but scalable . have 700 Multiple official and community extensions .

If you know you're going to develop a large Web application program , A more complete framework may need to be studied . The most popular in this category is Django.

15. BeautifulSoup

If you extracted some from the website HTML, It needs to be parsed to get the actual required content .Beautiful
Soup It's a Python library , Used from HTML and XML Extract data from file . It provides navigation , A simple way to search and modify the parse tree . It's very powerful , Even if it's damaged , Can also handle all kinds of HTML. believe me ,HTML Often destroyed , So this is a very powerful function .

Some of its main functions :

*
Bautiful Soup The incoming document is automatically converted to Unicode, Convert outgoing documents to UTF-8. You don't need to consider coding .

*
Beautiful Soup Located in popular Python Parser ( as lxml and html5lib) Top of , Enables you to try different parsing strategies or increase flexibility .

*
BeautifulSoup Any content you provide will be parsed , And do the work of traversing the tree for you . You can tell them “ Find all links ”, or “ Find table titles with bold , Then give me the text .

 

Technology