Home Backend Development Python Tutorial 推荐11个实用Python库

推荐11个实用Python库

Jun 10, 2016 pm 03:18 PM
python library

1) delorean

非常酷的日期/时间库

复制代码 代码如下:

from delorean import Delorean
EST = "US/Eastern"
d = Delorean(timezone=EST)

2) prettytable

可以在浏览器或终端构建很不错的输出

复制代码 代码如下:

from prettytable import PrettyTable
table = PrettyTable(["animal", "ferocity"])
table.add_row(["wolverine", 100])
table.add_row(["grizzly", 87])
table.add_row(["Rabbit of Caerbannog", 110])
table.add_row(["cat", -1])
table.add_row(["platypus", 23])
table.add_row(["dolphin", 63])
table.add_row(["albatross", 44])
table.sort_key("ferocity")
table.reversesort = True
+----------------------+----------+
|        animal        | ferocity |
+----------------------+----------+
| Rabbit of Caerbannog |   110    |
|      wolverine       |   100    |
|       grizzly        |    87    |
|       dolphin        |    63    |
|      albatross       |    44    |
|       platypus       |    23    |
|         cat          |    -1    |
+----------------------+----------+

3) snowballstemmer

非常瘦小的语言转换库,支持15种语言

复制代码 代码如下:

from snowballstemmer import EnglishStemmer, SpanishStemmer
EnglishStemmer().stemWord("Gregory")
# Gregori
SpanishStemmer().stemWord("amarillo")
# amarill

4) wget

Python的网络爬虫库

复制代码 代码如下:

import wget
wget.download("
# 100% [............................................................................] 280385 / 280385

5) PyMC

PyMC,一个用于贝叶斯分析的函数库

复制代码 代码如下:

from pymc.examples import disaster_model
from pymc import MCMC
M = MCMC(disaster_model)
M.sample(iter=10000, burn=1000, thin=10)
[-----------------100%-----------------] 10000 of 10000 complete in 1.4 sec

6) sh

将shell命令作为函数导入Python脚本

复制代码 代码如下:

from sh import find
find("/tmp")
/tmp/foo
/tmp/foo/file1.json
/tmp/foo/file2.json
/tmp/foo/file3.json
/tmp/foo/bar/file3.json

7) fuzzywuzzy

用于字符串匹配率、令牌匹配等

复制代码 代码如下:

from fuzzywuzzy import fuzz
fuzz.ratio("Hit me with your best shot", "Hit me with your pet shark")
# 85

8) progressbar

如其名,一个滚动条函数库

复制代码 代码如下:

from progressbar import ProgressBar
import time
pbar = ProgressBar(maxval=10)
for i in range(1, 11):
    pbar.update(i)
    time.sleep(1)
 pbar.finish()
# 60% |########################################################                                      |

9) colorama

一个色彩库,可以为文本添加丰富的色彩

10) uuid

一个可以产生唯一uuid的库

复制代码 代码如下:

import uuid
print uuid.uuid4()
# e7bafa3d-274e-4b0a-b9cc-d898957b4b61

11) bashplotlib

Python的绘图控件,可以绘制直方图、散点图等

复制代码 代码如下:

$ pip install bashplotlib
$ scatter --file data/texas.txt --pch x

以上就是本文推荐的11个使用的python库了,也许有些你没有见过,但都是些非常棒的pyton库,希望大家能够喜欢。

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

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

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

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

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