a6266318 发表于 2017-4-22 13:19:40

python组件总汇

1)xml
xml.etree.ElementTree可处理简单的,对xpath支持的不好,比如attr不支持
xpath可使用py-dom-xpath库:
import xpath
from xml.dom import minidom
doc = minidom.parse("../config/user.xml")
names = xpath.find("//name[@alias]", doc)
print names

2)html
Beautiful Soup
http://www.crummy.com/software/BeautifulSoup/
3)中文处理
4)url编码解码
使用urllib库。
5)图形处理
PIL
http://www.pythonware.com/library/pil/handbook/introduction.htm
6)excel
http://www.python-excel.org/
读xlrd
写xlwt
以上不支持2007
支持2007
http://pypi.python.org/pypi/openpyxl/1.1.0
7)email
http://canofy.iteye.com/blog/265600
http://www.codecho.com/send-mail-with-attachment-using-python/
8)json
simplejson
http://pypi.python.org/pypi/simplejson/
http://simplejson.readthedocs.org/en/latest/index.html
dumps把dict转换为json字符串,loads把json字符串转换为dict
python2.6默认支持
9)http
urllib
urllib2支持修改header
不建议使用urllib1和2,因为http的一些特性比如缓存、压缩和重定向支持的不好
建议使用httplib2
10)web
django用以提供http服务
11)http file upload
poster
http://atlee.ca/software/poster/
12)部署
fabric,instagram团队使用
http://docs.fabfile.org/en/1.4.2/index.html
页: [1]
查看完整版本: python组件总汇