资讯专栏INFORMATION COLUMN

11个你可能不知道的Python库

gnehc / 2065人阅读

摘要:非常酷的日期时间库可以在浏览器或终端构建很不错的输出

1) delorean

非常酷的日期/时间库

from delorean import Delorean
EST = "US/Eastern"
d = Delorean(timezone=EST)
2) prettytable
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

首发:http://blog.92fenxiang.com/articles/1421855937

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

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

相关文章

  • 10个你应该了解Git命令(以及Git省时小窍门)

    摘要:下面是需要了解的个命令和它们的一些常见标志。每个命令都链接到该命令的指南。仅用于提交级别。指定一个不同的提交,而不是来丢弃自提交以来的更改。包装在本文中,你已经看到了一些关键的命令,并配置了环境以节省时间。 showImg(https://segmentfault.com/img/remote/1460000018662396); 在本文中,我们将讨论那些作为开发人员、数据科学家或产品...

    laoLiueizo 评论0 收藏0
  • 职场经验之15个你必须知道Python面试题

    摘要:因为你可能需要在工作中与一些奇怪的人合作问题多线程使用。回答不允许真正意义上的多线程。在学习之前,很多人花了很多的时间在他们的多线程中遇到了瓶颈。 showImg(https://segmentfault.com/img/remote/1460000019609267); 介绍 随着人工智能、机器学习、深度学习的发展,这个领域也正在不断的进入人们的眼帘,并且带来了很多、很大的工作机会,...

    jayce 评论0 收藏0
  • [译]14个你可能知道JavaScript调试技巧

    摘要:在控制台中使用,当到达传入的函数时,代码将停止。但除了私有和匿名函数这可能是找到调试函数的最快方法。在控制台中输入,当调用时,将以调试模式停止屏蔽不相关代码现在,我们经常在应用中引入几个库或框架。 译者:SlaneYang原文:https://raygun.com/javascript-debugging-tips 以更快的速度和更高的效率来调试JavaScript 熟悉工具可以让工具...

    CODING 评论0 收藏0

发表评论

0条评论

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