Table of Contents
1. Dash
2. Pillow
3. Colorama
7. 进度条:progress和tqdm
progress
tqdm
8. Homeassistant
9. Python-dateutil
10. Pygame
Home Backend Development Python Tutorial Ten useful Python utility libraries, I recommend you try them!

Ten useful Python utility libraries, I recommend you try them!

Apr 13, 2023 am 09:43 AM
python code software package

Ten useful Python utility libraries, I recommend you try them!

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 the 230,000 user-contributed packages that make Python truly powerful and popular.

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

1. Dash

Dash is a Python library for building web-based applications without JavaScript.

Dash is also a user interface library for creating analytical web applications. Those who use Python for data analysis, data mining, visualization, modeling, instrument control, and reporting can use Dash right away.

Ten useful Python utility libraries, I recommend you try them!

Dash is built on Plotly.js, React, and Flask to combine modern UI elements like dropdowns, sliders, and graphs with your analytical Python code .

Project address:

​https://www.php.cn/link/502cc2c94be1a7c4ca7ef25b8b50bc04​

2. Pillow

Pillow is specifically designed for working with images, you can use this library to create thumbnails, convert between file formats, rotate, apply filters, display images and more. 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 (loading and rendering images):

Ten useful Python utility libraries, I recommend you try them!

Help documentation:

​https://www.php.cn/link/ae502204564aafbffb712be630e3910b​

​https://www.php.cn/link/52130c418d4f02c74f74a5bc1f8020b2​

3. 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.

Ten useful Python utility libraries, I recommend you try them!

Project address:

##​

​https://www.php.cn/link/23ef5cf238a3b88085d95adf94c24a25​

4. JmesPath

Working with JSON in Python is very easy because JSON maps very well to 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:

>>> import jmespath
>>> path = jmespath.search('foo.bar', {'foo': {'bar': 'baz'}})
'baz'
Copy after login

Project address:

​https://www.php.cn/link/ 14b7367a28377d4d513a4d3349861d2f​

5. Simplejson

What’s wrong with the local json module in Python? 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:

Ten useful Python utility libraries, I recommend you try them!

Project address:

​https://www.php.cn/link/3c51419c5607de9699da15be1274b4a6​

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

6. Emoji

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

Ten useful Python utility libraries, I recommend you try them!

project address:

​https://www.php.cn/link/988f9153ac4fd966ea302dd9ab9bae15​

7. 进度条:progress和tqdm

这里有点作弊,因为这是两个包,但忽略其中之一是不公平的。

您可以创建自己的进度条,这也许很有趣,但是使用progress或tqdm程序包更快,更不容易出错。

progress

借助这个软件包,您可以轻松创建进度条:

from progress.bar import Bar
bar = Bar('Processing', max=20)
for i in range(20):
# Do some work
bar.next()
bar.finish()
Copy after login

tqdm

tqdm的功能大致相同,但似乎是最新的。

from tqdm import tqdm
for i in tqdm(range(10000)):
...
Copy after login

以gif动画形式进行一些演示:

Ten useful Python utility libraries, I recommend you try them!

8. Homeassistant

home assistant是一个运行在python 3上的家庭自动化平台。它能够在家里对所有设备进行跟踪和控制,为自动化控制提供了一个平台。

Ten useful Python utility libraries, I recommend you try them!

它现在控制着我们房屋的大部分。我使用Home Assistant将房子中的所有系统捆绑在一起。尽管它确实是一个完整的应用程序,但是您也可以将其安装为Python PyPI软件包。

  • 大多数灯具都是自动化的,百叶窗也是如此。
  • 监视我们的天然气用量,电力用量和产量(太阳能电池板)。
  • 可以跟踪大多数电话的位置,并在进入一个区域时开始操作,例如当我回家时打开车库灯。
  • 它还可以控制我们所有的娱乐系统,例如三星电视和Sonos扬声器。
  • 它能够自动发现网络上的大多数设备,因此上手起来非常容易。  

   项目地址:

​https://www.php.cn/link/16002f7a455a94aa4e91cc34ebdb9f2d​

9. Python-dateutil

python-dateutil模块提供了对标准datetime模块的强大扩展。

您可以使用此库做很多很棒的事情。比如计算相对增量(下个月,明年,下周一,该月的最后一周等)和两个给定日期对象之间的相对增量。

项目地址:

​https://www.php.cn/link/a35d11c2f995c60b0341a9c777f1ae03​

10. Pygame

Pygame 是一组用来开发游戏软件的 Python 程序模块,基于 SDL 库的基础上开发。

Ten useful Python utility libraries, I recommend you try them!

允许你在 Python 程序中创建功能丰富的游戏和多媒体程序,旨在提供对以下内容的低级接口:

  • 音频
  • 键盘
  • 鼠标
  • 游戏杆
  • 基于OpenGL和Direct3D的图形硬件

Pygame具有高度的可移植性,几乎可以在所有平台和操作。

The above is the detailed content of Ten useful Python utility libraries, I recommend you try them!. 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)

Hot Topics

Java Tutorial
1655
14
PHP Tutorial
1252
29
C# Tutorial
1226
24
PHP and Python: Different Paradigms Explained PHP and Python: Different Paradigms Explained Apr 18, 2025 am 12:26 AM

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

Choosing Between PHP and Python: A Guide Choosing Between PHP and Python: A Guide Apr 18, 2025 am 12:24 AM

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP and Python: A Deep Dive into Their History PHP and Python: A Deep Dive into Their History Apr 18, 2025 am 12:25 AM

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

Python vs. JavaScript: The Learning Curve and Ease of Use Python vs. JavaScript: The Learning Curve and Ease of Use Apr 16, 2025 am 12:12 AM

Python is more suitable for beginners, with a smooth learning curve and concise syntax; JavaScript is suitable for front-end development, with a steep learning curve and flexible syntax. 1. Python syntax is intuitive and suitable for data science and back-end development. 2. JavaScript is flexible and widely used in front-end and server-side programming.

How to run sublime code python How to run sublime code python Apr 16, 2025 am 08:48 AM

To run Python code in Sublime Text, you need to install the Python plug-in first, then create a .py file and write the code, and finally press Ctrl B to run the code, and the output will be displayed in the console.

Can vs code run in Windows 8 Can vs code run in Windows 8 Apr 15, 2025 pm 07:24 PM

VS Code can run on Windows 8, but the experience may not be great. First make sure the system has been updated to the latest patch, then download the VS Code installation package that matches the system architecture and install it as prompted. After installation, be aware that some extensions may be incompatible with Windows 8 and need to look for alternative extensions or use newer Windows systems in a virtual machine. Install the necessary extensions to check whether they work properly. Although VS Code is feasible on Windows 8, it is recommended to upgrade to a newer Windows system for a better development experience and security.

Where to write code in vscode Where to write code in vscode Apr 15, 2025 pm 09:54 PM

Writing code in Visual Studio Code (VSCode) is simple and easy to use. Just install VSCode, create a project, select a language, create a file, write code, save and run it. The advantages of VSCode include cross-platform, free and open source, powerful features, rich extensions, and lightweight and fast.

How to run python with notepad How to run python with notepad Apr 16, 2025 pm 07:33 PM

Running Python code in Notepad requires the Python executable and NppExec plug-in to be installed. After installing Python and adding PATH to it, configure the command "python" and the parameter "{CURRENT_DIRECTORY}{FILE_NAME}" in the NppExec plug-in to run Python code in Notepad through the shortcut key "F6".

See all articles