背景:
閱讀新聞
11個實用但你可能不知道的Python程序庫
[日期:2015-01-29]
來源:CSDN
作者:Linux
[字體:大 中 小]
目前,網(wǎng)上已有成千上萬個Python包,但幾乎沒有人能夠全部知道它們续镇。單單PyPi上就有超過47000個包列表。
現(xiàn)在,越來越多的數(shù)據(jù)科學(xué)家開始使用Python,雖然他們從pandas,scikit-learn,numpy中獲得了不少好處,但我仍想向他們介紹一些年長且非常實用的Python庫澄者。在本文中,我將列一些不太知名的庫,即使你是經(jīng)驗豐富的Python的開發(fā)者,也值得過來一看听怕。
1) delorean
Dolorean是一個非常酷的日期/時間庫。類似JavaScript的moment,擁有非常完善的技術(shù)文檔正压。
from delorean import Delorean
EST = "US/Eastern"
d = Delorean(timezone=EST)
2) prettytable
你可能從未聽過該庫,因為它托管在GoogleCode瓷式。prettytable主要用于在終端或瀏覽器端構(gòu)建很好的輸出替饿。
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
好吧,我也是首次安裝該庫。這是一款非常瘦小的語言轉(zhuǎn)換庫,支持15種語言蒿往。
fr九度快排系統(tǒng) https://www.190seo.comom snowballstemmer import EnglishStemmer, SpanishStemmer
EnglishStemmer().stemWord("Gregory")
# Gregori
SpanishStemmer().stemWord("amarillo")
# amarill
4.wget
你是否還記得,每一次都會因為某個目的而編寫網(wǎng)絡(luò)爬蟲工具,以后再也不用了,因為wget就足夠你使用了盛垦。wget是Python版的網(wǎng)絡(luò)爬蟲庫,簡單好用湿弦。
import wget
wget.download("http://www.cnn.com/")
# 100% [............................................................................] 280385 / 280385
備注:linux和osx用戶這樣用:from
sh import wget瓤漏。但是,wget模塊還有一個更好的argument handline。
5.PyMC
scikit-learn似乎是所有人的寵兒,但在我看來,PyMC更有魅力颊埃。PyMC主要用來做Bayesian分析蔬充。
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
sh庫用來將shell命令作為函數(shù)導(dǎo)入到Python中。在bash中使用是非常實用的,但是在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
Fuzzywuzzy是一個可以對字符串進行模糊匹配的庫,大家有空可以去查看源碼饥漫。
from fuzzywuzzy import fuzz
fuzz.ratio("Hit me with your best shot", "Hit me with your pet shark")
# 85
8.progressbar
progressbar是一個進度條庫,該庫提供了一個文本模式的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
colorama主要用來給文本添加各種顏色,并且非常簡單易用罗标。
10.uuid
uuid是基于Python實現(xiàn)的UUID庫,它實現(xiàn)了UUID標(biāo)注的1,3,4和5版本,在確保唯一性上真的非常方便庸队。
import uuid
print uuid.uuid4()
# e7bafa3d-274e-4b0a-b9cc-d898957b4b61
11.bashplotlib
bashplotlib是一個繪圖庫,它允許你使用stdin繪制柱狀圖和散點圖等。
$ pip install bashplotlib
$ scatter --file data/texas.txt --pch x
英文原文:11 Python Libraries You Might Not Know
--------------------------------------分割線 --------------------------------------
CentOS上源碼安裝Python3.4 http://www.linuxidc.com/Linux/2015-01/111870.htm
《Python核心編程 第二版》.(Wesley J. Chun ).[高清PDF中文版] http://www.linuxidc.com/Linux/2013-06/85425.htm
《Python開發(fā)技術(shù)詳解》.( 周偉,宗杰).[高清PDF掃描版+隨書視頻+代碼] http://www.linuxidc.com/Linux/2013-11/92693.htm
Python腳本獲取Linux系統(tǒng)信息 http://www.linuxidc.com/Linux/2013-08/88531.htm
在Ubuntu下用Python搭建桌面算法交易研究環(huán)境 http://www.linuxidc.com/Linux/2013-11/92534.htm
Python 語言的發(fā)展簡史 http://www.linuxidc.com/Linux/2014-09/107206.htm
Python 的詳細介紹:請點這里
Python 的下載地址:請點這里
本文永久更新鏈接地址:http://www.linuxidc.com/Linux/2015-01/112556.htm
Objective-C的陷阱與缺陷
AngularJS入門講解1:angular基本概念
相關(guān)資訊
Python程序 Python程序庫
4個備受歡迎的Python程序庫 你用哪 (02月21日)
Python寫的ATM小程序 (09/27/2014 06:41:35)
Python 小程序,實現(xiàn)比較兩個列表 (02/15/2014 18:56:50)
PHP中調(diào)用Python程序 (12/04/2015 15:06:16)
Python環(huán)境中運行程序 (08/14/2014 06:30:56)
用Python寫的一個小小的回收站定時 (12/18/2013 20:15:55)
本文評論
查看全部評論 (0)
表情:
姓名:
匿名
字數(shù)
同意評論聲明
評論聲明
尊重網(wǎng)上道德,遵守中華人民共和國的各項有關(guān)法律法規(guī)
承擔(dān)一切因您的行為而直接或間接導(dǎo)致的民事或刑事法律責(zé)任
本站管理人員有權(quán)保留或刪除其管轄留言中的任意內(nèi)容
本站有權(quán)在網(wǎng)站內(nèi)轉(zhuǎn)載或引用您的評論
參與本評論即表明您已經(jīng)閱讀并接受上述條款
最新資訊
CentOS 6.4下雙網(wǎng)卡bond配置
CentOS6.x雙網(wǎng)卡采用主-備份策略綁定(bond
ORA-30036故障解決方法案例
ORA-03114: 未連接到 ORALCE 解決方法案例
Oracle RAC系統(tǒng)內(nèi)存無法釋放解決
Oracle Goldengate在HP平臺裸設(shè)備文件系統(tǒng)
OGG升級運行g(shù)gsic報Unable to find library
Linux vi命令大全
VMware虛擬機主機模式下與主機互ping通
Linux內(nèi)核中container_of函數(shù)詳解