日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

转:11个实用但你可能不知道的Python程序库

發布時間:2024/10/12 python 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 转:11个实用但你可能不知道的Python程序库 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

原文來自于:http://www.techug.com/11-python-libraries-you-might-not-know

目前,網上已有成千上萬個Python包,但幾乎沒有人能夠全部知道它們。單單PyPi上就有超過47000個包列表。

現在,越來越多的數據科學家開始使用Python,雖然他們從pandas,scikit-learn,numpy中獲得了不少好處,但我仍想向他們介紹一些年長且非常實用的Python庫。在本文中,我將列一些不太知名的庫,即使你是經驗豐富的Python的開發者,也值得過來一看。

1)?delorean

Dolorean是一個非常酷的日期/時間庫。類似JavaScript的moment,擁有非常完善的技術文檔。

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

2)?prettytable

你可能從未聽過該庫,因為它托管在GoogleCode。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

你是否還記得,每一次都會因為某個目的而編寫網絡爬蟲工具,以后再也不用了,因為wget就足夠你使用了。wget是Python版的網絡爬蟲庫,簡單好用。

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命令作為函數導入到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實現的UUID庫,它實現了UUID標注的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

轉載于:https://www.cnblogs.com/guoyongrong/p/4260564.html

總結

以上是生活随笔為你收集整理的转:11个实用但你可能不知道的Python程序库的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。