资讯专栏INFORMATION COLUMN

推荐11个实用Python库

stackfing / 3007人阅读

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库,希望大家能够喜欢。以上代码可以来raquant镭矿平台自己试试,无需安装Python即可在线运行。

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/38534.html

相关文章

  • 实用Python 学习资源汇总

    摘要:链接中文翻译常用库推荐除了上面提到的之外,也是一个很好的选项。官网中文翻译如果你要编写简单的爬虫,来爬去互联网上的信息,或者调用一些外部的机遇的接口,使用这个库再也合适不过了。 作者:安龙 LeanCloud 工程师 引言 :前段时间有同学反映 Python 的学习资源汇总很少。那么学习资料哪个质量更好,效率更高?Python 有哪些非常值得学习的库?2017 年了学 2 还是学 3 ...

    宠来也 评论0 收藏0
  • Python数据分析实用程序

    摘要:机器学习由于数据量较大,技术已成为必要。以下脚本演示了世界银行数据的线性回归实用程序和缓存下载程序省略了水印和绘图标签的代码代码应显示以下图像该计划下载年世界银行数据,并将婴儿死亡率与人均进行对比。 showImg(https://segmentfault.com/img/remote/1460000019179713); 来源 | 愿码(ChainDesk.CN)内容编辑 愿码Sl...

    mozillazg 评论0 收藏0

发表评论

0条评论

最新活动
阅读需要支付1元查看
<