Python 常用的标准库以及第三方库有哪些?
回复内容:
只介绍我用过觉得有强烈推荐欲望的几个=====================标准库
* 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推荐SQLAlchemy Python资源大全 去这个地方看看,Python常用模块基本都包括啦,而且还有很多学校资料 功能型的都是各取所需 就说些好用的吧
Tornado: 和其他Python框架的架构可谓大相径庭,Request的处理方式也很舒服,特别适合REST,谁用谁知道
Mako: 个人认为是最好的Template,简单 性能好
SQLAlchemy: 快一统ORM了吧
Quixote:其实还是蛮好用的
pyQuery: 用jQuery的语法写爬虫 略爽
gevent。。。。。 推荐两个 BeautifulSoup 和 IMage
20 Python libraries you can't live withouthttps://freepythontips.wordpress.com/2013/07/30/20-python-libraries-you-cant-live-without/ requests 好用的让人想哭 一个memo: https://github.com/fengsp/easy-python
By Yasoob •
wordpress.com • July 30, 2013Hi 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.
或者直接: http://easy-python.readthedocs.org/ 我也来说两个:
操作系统相关的os库
python程序本身相关的sys库
配置文件解析的ConfigParser库
redis python客户端pyredis
另外还有itertool,subprocess等
web框架:web.py flask django