Home Backend Development Python Tutorial Introducing 15 python libraries that are so useful that they make you cry

Introducing 15 python libraries that are so useful that they make you cry

Jan 04, 2021 am 09:44 AM
python library

Python video tutorialThe column introduces 15 useful python libraries

Introducing 15 python libraries that are so useful that they make you cry

Recommended (free): Python video tutorial

Why do I like Python? It's an easy-to-learn programming language for beginners, for another reason: the large number of third-party libraries available out of the box, and 230,000 user-contributed packages that make Python truly powerful and popular.

In this article, I selected 15 of the most useful software packages and introduced their functions and features.

1. Dash

Dash is a relatively new package that is ideal for building data visualization apps in pure Python, making it especially suitable for anyone working with data. . Dash is a hybrid of Flask, Plotly.js and React.js.

Introducing 15 python libraries that are so useful that they make you cry

2. Pygame

Pygame is the Python decorator of the SDL multimedia library. SDL (Simple DirectMedia Layer) is a cross-platform Development library designed to provide a low-level interface to:

  • Audio

  • Keyboard

  • Mouse

  • Joystick

  • OpenGL and Direct3D based graphics hardware

Pygame has a high Portable and can run on almost all platforms and operating systems. Although it has a complete game engine, you can also use this library to play MP3 files directly from Python scripts.

3. Pillow

Pillow is specially designed for processing images, you can use this library to create thumbnails, convert between file formats, rotate, apply filters, Display images and so on. This is ideal if you need to perform batch operations on many images.

To understand it quickly, take a look at the following code example (which loads and renders the image):

Introducing 15 python libraries that are so useful that they make you cry

4. Colorama

Colorama allows you to work with colors in the terminal, perfect for Python scripts, the documentation is short and sweet and can be found on the Colorama PyPI page.

Introducing 15 python libraries that are so useful that they make you cry

5. JmesPath

Working with JSON in Python is very easy because JSON maps very well on Python dictionaries. Additionally, Python comes with its own excellent json library for parsing and creating JSON. To me, this is one of its best features. If I need to work with JSON, I might consider using Python.

JMESPath makes processing JSON in Python easier by allowing you to explicitly specify how to extract elements from a JSON document. Here are some basic examples to give you an idea of ​​its capabilities:

Introducing 15 python libraries that are so useful that they make you cry

6. Requests

Requests are built on The world's most downloaded Python library, urllib3, makes web requests very simple, powerful and versatile.

The following code example illustrates how simple it is to use requests.

Introducing 15 python libraries that are so useful that they make you cry

Requests can do all the advanced stuff you can think of, such as:

  • Authentication

  • Use cookies

  • Perform POST, PUT, DELETE, etc.

  • Use custom certificate

  • Use SessionSession

  • Use Proxy

7. Simplejson

Local in Python What's wrong with the json module? No! Actually, Python's json is simplejson. Meaning, Python took a version of simplejson and incorporated it into every distribution. But using simplejson has some advantages:

  • It works on more Python versions.

  • It is updated more frequently than the version that comes with Python.

  • It has the (optional) part written in C, so it's very fast.

Due to these facts, you will often see the following in scripts that use JSON:

Introducing 15 python libraries that are so useful that they make you cry

I will just use the default json, unless you specifically need it:

  • Speed

  • Things not in the standard library

Simplejson is much faster than json because it implements some key parts in C. Unless you are processing millions of JSON files, you won't be interested in this kind of speed.

8. Emoji

The Emoji library is very interesting, but not everyone likes emoticons. Emoji packages are very useful when analyzing perspective media data.

Introducing 15 python libraries that are so useful that they make you cry

The following is a simple code example:

Introducing 15 python libraries that are so useful that they make you cry

9. Chardet

You You can use the chardet module to detect the character set of a file or data stream. This is useful when analyzing large amounts of random text, for example. However, it can also be used when working with remotely downloaded data when you don't know what the character set is.

10. Python-dateutil

The python-dateutil module provides powerful extensions to the standard datetime module. My experience is that where regular Python datetime functionality ends, python-dateutil comes in.

You can do a lot of cool things with this library. I've limited these examples to ones I've found particularly useful: Fuzzy analysis of dates in log files, for example:

Introducing 15 python libraries that are so useful that they make you cry

See the full documentation for more features, for example:

  • Calculate the relative delta (next month, next year, next Monday, last week of the month, etc.) and the relative delta between two given date objects.

  • Uses a superset of the iCalendar specification to calculate dates based on repetition rules.

  • Time zone (tzinfo) implementation of tzfile files (/etc/localtime, /usr/share/zoneinfo, etc.), TZ environment strings (all known formats), iCalendar format files, Given a range (with the help of relative increments), local machine time zone, fixed offset time zone, UTC time zone and Windows registry based time zone.

  • Internal latest world time zone information based on the Olson database.

  • Calculate the Easter Sunday date for any year using the Western, Orthodox or Julian algorithm.

11. Progress bar: progress and tqdm

A little cheating here, since these are two packages, but it is not possible to ignore one of them Fair.

You can create your own progress bar, which might be fun, but using the progress or tqdm packages is faster and less error-prone.

progress

With the help of this package you can easily create progress bars:

Introducing 15 python libraries that are so useful that they make you cry

Introducing 15 python libraries that are so useful that they make you cry

tqdm

tqdm does roughly the same thing but seems to be the latest. First some demonstrations in the form of animated gifs:

Introducing 15 python libraries that are so useful that they make you cry

12. IPython

Introducing 15 python libraries that are so useful that they make you cry

I’m sure You know Python's interactive shell, which is a great way to run Python. But do you also know the IPython shell? If you use interactive shells regularly but you don't know IPython, you should check it out!

Some of the features provided by the enhanced IPython shell include:

  • Comprehensive object introspection.

  • Input history persists across sessions.

  • Cache output results during a session with automatically generated references.

  • Tab completion, by default supports completion of python variables and keywords, file names and function keywords.

  • "Magic" command used to control the environment and perform many IPython or operating system related tasks.

  • Session recording and reloading.

  • Integrated access to the pdb debugger and Python profiler.

  • A little-known feature of IPython: its architecture also allows for parallel and distributed computing.

IPython is at the heart of Jupyter Notebook, an open source web application that lets you create and share documents containing live code, equations, visualizations, and narrative text.

13. Homeassistant

Introducing 15 python libraries that are so useful that they make you cry

I love home automation. It was a bit of a hobby for me, but one I still feel deeply sorry for as it now controls a large portion of our house. I use Home Assistant to tie together all the systems in the house. Although it is indeed a complete application, you can also install it as a Python PyPI package.

  • Most of our light fixtures are automated, as are our blinds.

  • I monitor our natural gas usage, electric usage and production (solar panels).

  • I can track the location of most phones and initiate actions when they enter an area, such as turning on the garage lights when I get home.

  • It can also control all our entertainment systems such as Samsung TVs and Sonos speakers.

  • It can automatically discover most devices on the network, so it is very easy to get started.

I've been using Home Assistant every day for 3 years, it's still in beta, but it's the best platform out of all the ones I've tried. It is able to integrate and control a variety of devices and protocols, and is all free and open source.

If you are interested in automating your home, make sure you get the chance! If you want to know more, please visit their official website. If you can, install it on your Raspberry Pi. This is by far the easiest and safest way to get started. I installed it on a more powerful server inside a Docker container.

14. Flask

Flask is my go-to library for creating fast web services or simple websites. This is a microframework, which means that Flask aims to keep the core simple but extensible. There are over 700 official and community extensions.

If you know you will be developing a large web application, you may want to look into a more complete framework. The most popular in this category is Django.

15. BeautifulSoup

If you extracted some HTML from your website, you need to parse it to get the actual content you want. Beautiful Soup is a Python library for extracting data from HTML and XML files. It provides simple methods to navigate, search and modify parse trees. It's very powerful and, even if broken, is capable of handling all kinds of HTML. Trust me, HTML is often broken, so this is a very powerful feature.

Some of its main features:

  • Beautiful Soup automatically converts incoming documents to Unicode and outgoing documents to UTF-8. You don't need to think about coding.

  • Beautiful Soup sits on top of popular Python parsers such as lxml and html5lib, allowing you to try different parsing strategies or increase flexibility.

  • BeautifulSoup parses whatever you provide and does the work of walking the tree for you. You can tell it "Find all links," or "Find the table title with bold font and give me that text."

The above is the detailed content of Introducing 15 python libraries that are so useful that they make you cry. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to install python library in Tsinghua Mirror How to install python library in Tsinghua Mirror Nov 24, 2023 pm 02:09 PM

Steps to install the python library with Tsinghua mirror: 1. Open the terminal or command line interface; 2. Make sure that the Tsinghua mirror source has been configured and set the Tsinghua mirror source as the default source of pip; 3. Run "pip install <package-name> " command to install the Python library; 4. If you need to install a specific version of the library, you can add the version number "pip install <package-name>@<version>" after the installation command.

What is the best Python library for hidden Markov models? What is the best Python library for hidden Markov models? Aug 30, 2023 pm 06:45 PM

Hidden Markov Models (HMMs) are a powerful type of statistical model used for modeling sequence data. They have uses in numerous fields including speech recognition, natural language processing, finance, and bioinformatics. Python is a versatile programming language that provides a series of libraries for implementing HMMs. In this article, we will discover unique Python libraries for HMMs and evaluate their functionality, performance and ease of use, sooner or later revealing the best option for your needs. Getting Started with Hidden Markov Models Before diving into these libraries, let’s briefly review the concept of HMMs. HMM is a probabilistic model that represents the transition of a system between hidden states over time. It consists of the following parts - a set of hidden states initial state probability distribution state transition

Delete pip with one click: Easily clean up redundant files in Python libraries! Delete pip with one click: Easily clean up redundant files in Python libraries! Jan 16, 2024 am 08:44 AM

Quickly uninstall pip: simple operation, clean up useless Python libraries! Article summary: When we use Python to develop projects, we may install many Python libraries, and some libraries may become useless due to changes in project requirements or other reasons. In this case, uninstalling these useless Python libraries can help us save disk space and keep the project tidy. This article will introduce a method to quickly uninstall pip, as well as specific code examples. Text: Python is a very powerful programming language

Use Tsinghua mirror to speed up the construction of Python library installation environment Use Tsinghua mirror to speed up the construction of Python library installation environment Jan 16, 2024 am 09:26 AM

Use Tsinghua mirror to quickly build a Python library installation environment Introduction: Python is a widely used programming language with a wealth of third-party libraries. When developing projects using Python, you often encounter situations where you need to install various libraries. However, due to limitations of the domestic network environment, sometimes the library download speed from PyPI (PythonPackageIndex) will be very slow or even impossible to connect. In this case, we can use the Tsinghua University mirror station to provide high-speed downloading through the mirror station.

Learn how to install Python libraries using domestic sources: a simple guide for beginners Learn how to install Python libraries using domestic sources: a simple guide for beginners Jan 17, 2024 am 09:35 AM

In the daily Python programming process, various third-party libraries are often used. Pip is the most commonly used package management tool for Python. By using it to install and upgrade Python packages, you can make Python programming more efficient and easier. However, due to the differences between domestic and foreign network environments, you may feel confused when using pip to install the Python library. This article will introduce you to some pip tips for installing Python libraries from domestic sources that even novices can learn, and provide specific code examples. Modify pip configuration

Share how to quickly install the Python library under the Tsinghua mirror Share how to quickly install the Python library under the Tsinghua mirror Jan 16, 2024 am 10:57 AM

Tsinghua Mirror shares how to quickly install Python libraries, requiring specific code examples. With the widespread application of Python in data analysis, artificial intelligence and other fields, installing Python libraries has become one of the essential skills for every Python developer. However, due to the usage needs of many developers, domestic and foreign mirror sites may have problems such as slow download speeds and installation failures. In order to solve this problem, Tsinghua University provides domestic users with a Tsinghua Mirror Station to speed up the downloading and installation of Python libraries. This article will introduce the use of clear

Learn about pip acceleration commands to speed up Python library downloads Learn about pip acceleration commands to speed up Python library downloads Jan 27, 2024 am 09:59 AM

To understand the pip acceleration command to speed up the download of Python libraries, specific code examples are required. With the popularity and widespread application of the Python language, using the pip tool to install and manage Python libraries has become an important part of developers' daily work. However, due to network limitations, pip sometimes encounters slow speed when downloading Python libraries, which not only affects development efficiency, but may also delay project progress. To solve this problem, we can speed up Pyt by using the pip speedup command

How to use python library How to use python library Nov 10, 2023 pm 03:42 PM

Python libraries are used through the steps of importing the library, using functions and constants in the library, aliases, and viewing the documentation in the library. Commonly used Python libraries include: 1. Numpy; 2. Pandas; 3. Matplotlib; 4. Requests; 5. TensorFlow.

See all articles