Python 常用的標準庫以及第三方庫有哪些?

來源:互聯網
上載者:User

回複內容:

只介紹我用過覺得有強烈推薦慾望的幾個

=====================標準庫
* http://docs.python.org/library/argparse.html
寫命令列指令碼必備,可惜是2.7才添加的,得看具體環境了…

* http://docs.python.org/library/htmlparser.html
解析HTML DOM樹,偶爾搞搞命令列自動表單提交用得上。感覺不好用但是畢竟是官方庫

=====================第三方庫

* http://pypi.python.org/pypi/sh
簡直是系統管理神器,誰用誰知道

* http://pypi.python.org/pypi/suds
輕量的SOAP用戶端,如果貴廠內部有用SOAP介面,那這個幾乎是必須了

* http://pypi.python.org/pypi/requests
這個HTTP lib的名字叫Python HTTP for Human。用過urllib、urllib2、httplib的人,你懂的

* http://pypi.python.org/pypi/pelican
* http://pypi.python.org/pypi/Markdoc
前者是靜態部落格產生器(寫markdown文本,然後自動轉換成html靜態檔案),後者是文檔產生器(以前拿這個做wiki用)

* http://pypi.python.org/pypi/pep8
檢查Python指令碼是否符合PEP8的style guide

* http://pypi.python.org/pypi/Pygments
文法高亮的lib,很多ruby項目用的都是這個python lib來做文法高亮的

其他想到了再補充吧我也來幾個吧
standard libs:
  • itertools http://docs.python.org/2/library/itertools.html
  • functools http://docs.python.org/2/library/functools.html 學好python有必要掌握上面這兩個庫吧,
  • re 正則
  • subprocess http://docs.python.org/2/library/subprocess.html 調用shell命令的神器
  • pdb 調試
  • traceback 調試
  • pprint 漂亮的輸出
  • logging 日誌
  • threading和multiprocessing 多線程
  • urllib/urllib2/httplib http庫,httplib底層一點,推薦第三方的庫requests
  • os/sys 系統,環境相關
  • Queue 隊列
  • pickle/cPickle 序列化工具
  • hashlib md5, sha等hash演算法
  • cvs
  • json/simplejson python的json庫,據so上的討論和benchmark,simplejson的效能要高於json
  • timeit 計算代碼啟動並執行時間等等
  • cProfile python效能測量模組
  • glob 類似與listfile,可以用來尋找檔案
  • atexit 有一個註冊函數,可用於正好在指令碼退出運行前執行一些代碼
  • dis python 反組譯碼,當對某條語句不理解原理時,可以用dis.dis 函數來查看代碼對應的python 解譯器指令等等。

3th libs:
  • paramiko https://github.com/paramiko/paramiko ssh python 庫
  • selenium https://pypi.python.org/pypi/selenium 瀏覽器自動化測試載入器selenium的python 介面
  • lxml http://lxml.de/ python 解析html,xml 的神器
  • mechanize https://pypi.python.org/pypi/mechanize/ Stateful programmatic web browsing
  • pycurl https://pypi.python.org/pypi/pycurl cURL library module for Python
  • Fabric http://docs.fabfile.org/en/1.8/ Fabric is a Python (2.5 or higher) library and command-line tool for streamlining the use of SSH for application deployment or systems administration tasks.
  • xmltodict https://github.com/martinblech/xmltodict xml 轉 dict,真心好用
  • urllib3 和 requests: 當然其實requests就夠了 Requests: HTTP for Humans
  • flask http://flask.pocoo.org/python web 微架構
  • ipdb 調試神器,同時推薦ipython!結合ipython使用
  • redis redis python介面
  • pymongo mongodbpython介面
  • PIL http://www.pythonware.com/products/pil/ python影像處理
  • mako http://www.makotemplates.org/ python模版引擎
  • numpy , scipy 科學計算
  • matplotlib 畫圖
  • scrapy 爬蟲
  • django/tornado/web.py/web2py/uliweb/flask/twisted/bottle/cherrypy.等等 python web架構/伺服器
  • sh 1.08 — sh v1.08 documentation 用來運行shell 模組的 極佳選擇


暫時記得這麼多吧,不過都是我自己常用的庫 :) 。。歡迎補充

UPDATE:
A curated list of awesome Python frameworks, libraries and software.

vinta/awesome-python · GitHub

幾乎所有很贊的 python 庫,和架構都在這個列表裡。

其他的 awesome list:
bayandin/awesome-awesomeness · GitHub 原生:
系統調用的subprocess
多線程的multiprocessing

第三方:
系統管理推薦fabric和salt
WEB架構推薦flask和tornado
ORM推薦SQLAlchemyPython資源大全 去這個地方看看,Python常用模組基本都包括啦,而且還有很多學校資料 功能型的都是各取所需 就說些好用的吧

Tornado: 和其他Python架構的架構可謂大相徑庭,Request的處理方式也很舒服,特別適合REST,誰用誰知道

Mako: 個人認為是最好的Template,簡單 效能好

SQLAlchemy: 快一統ORM了吧

Quixote:其實還是蠻好用的

pyQuery: 用jQuery的文法寫爬蟲 略爽

gevent。。。。。推薦兩個 BeautifulSoup 和 IMage
20 Python libraries you can't live without

By Yasoob •
wordpress.com • July 30, 2013

Hi there fellas. Today i am going to list 20 python libraries which have been a part of my toolbelt and should be a part of yours as well. So here they are:

1.Requests. The most famous http library written by kenneth reitz. It’s a must have for every python developer.

2.Scrapy. If you are involved in webscraping then this is a must have library for you. After using this library you won’t use any other.

3.wxPython. A gui toolkit for python. I have primarily used it in place of tkinter. You will really love it.

4.Pillow. A friendly fork of PIL (Python Imaging Library). It is more user friendly than PIL and is a must have for anyone who works with images.

5.SQLAlchemy. A database library. Many love it and many hate it. The choice is yours.

6.BeautifulSoup. I know it’s slow but this xml and html parsing library is very useful for beginners.

7.Twisted. The most important tool for any network application developer. It has a very beautiful api and is used by a lot of famous python developers.

8.NumPy. How can we leave this very important library ? It provides some advance math functionalities to python.

9.SciPy. When we talk about NumPy then we have to talk about scipy. It is a library of algorithms and mathematical tools for python and has caused many scientists to switch from ruby to python.

10.matplotlib. A numerical plotting library. It is very useful for any data scientist or any data analyzer.

11.Pygame. Which developer does not like to play games and develop them ? This library will help you achieve your goal of 2d game development.

12.Pyglet. A 3d animation and game creation engine. This is the engine in which the famous python port of minecraft was made

13.pyQT. A GUI toolkit for python. It is my second choice after wxpython for developing GUI’s for my python scripts.

14.pyGtk. Another python GUI library. It is the same library in which the famous Bittorrent client is created.

15.Scapy. A packet sniffer and analyzer for python made in python.

16.pywin32. A python library which provides some useful methods and classes for interacting with windows.

17.nltk. Natural Language Toolkit – I realize most people won’t be using this one, but it’s generic enough. It is a very useful library if you want to manipulate strings. But it’s capacity is beyond that. Do check it out.

18.nose. A testing framework for python. It is used by millions of python developers. It is a must have if you do test driven development.

19.SymPy. SymPy can do algebraic evaluation, differentiation, expansion, complex numbers, etc. It is contained in a pure Python distribution.

20.IPython. I just can’t stress enough how useful this tool is. It is a python prompt on steroids. It has completion, history, shell capabilities, and a lot more. Make sure that you take a look at it.

https://freepythontips.wordpress.com/2013/07/30/20-python-libraries-you-cant-live-without/ requests 好用的讓人想哭一個memo: https://github.com/fengsp/easy-python
或者直接: http://easy-python.readthedocs.org/ 我也來說兩個:
作業系統相關的os庫
python程式本身相關的sys庫
設定檔解析的ConfigParser庫
redis python用戶端pyredis
另外還有itertool,subprocess等

web架構:web.py flask django
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.