Python基础

Python

pip更改镜像

pip install -i [镜像url] [包名称]
如:
从清华镜像安装scrapy包

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple scrapy

常用源:
(1)阿里云 http://mirrors.aliyun.com/pypi/simple/
(2)豆瓣http://pypi.douban.com/simple/
(3)清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
(4)中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/
(5)华中科技大学http://pypi.hustunique.com/

常用包:
一、Web框架:

Tornado,访问:http://www.tornadoweb.org/en/stable/

Flask,访问:http://flask.pocoo.org/

Web.py,访问:http://webpy.org/

django:https://www.djangoproject.com/

cherrypy:http://cherrypy.org/

jinjs:http://docs.jinkan.org/docs/jinja2/

二、GUI 图形界面

Tkinter :https://wiki.python.org/moin/TkInter/

wxPython:https://www.wxpython.org/

PyGTK:http://www.pygtk.org/

PyQt:https://sourceforge.net/projects/pyqt/

PySide:http://wiki.qt.io/Category:LanguageBindings::PySide

三、科学计算

numpy:http://www.numpy.org/

SciPy:https://www.scipy.org/

pandas: http://pandas.pydata.org/

blaze: http://blaze.readthedocs.io/en/latest/index.html

四、密码学

cryptography:https://pypi.python.org/pypi/cryptography/

hashids:http://www.oschina.net/p/hashids

Paramiko:http://www.paramiko.org/

Passlib:https://pythonhosted.org/passlib/

PyCrypto:https://pypi.python.org/pypi/pycrypto

PyNacl:http://pynacl.readthedocs.io/en/latest/

五、爬虫相关

scrapy:https://scrapy.org/

pyspider: https://github.com/binux/pyspider

portia:https://github.com/scrapinghub/portia

html2text:https://github.com/Alir3z4/html2text

BeautifulSoup:https://www.crummy.com/software/BeautifulSoup/

lxml:http://lxml.de/

selenium:http://docs.seleniumhq.org/

mechanize:https://pypi.python.org/pypi/mechanize

PyQuery:https://pypi.python.org/pypi/pyquery/

creepy:https://pypi.python.org/pypi/creepy

gevent,一个高并发的网络性能库,访问:http://www.gevent.org/

requests,最好用的http工具,访问:http://www.python-requests.org/

六、图像处理

bigmoyan:http://scikit-image.org/

Python Imaging Library(PIL):

http://www.pythonware.com/products/pil/

pillow: http://pillow.readthedocs.io/en/latest/

七、自然语言处理

nltk: http://www.nltk.org/

snownlp: https://github.com/isnowfy/snownlp

Pattern:https://github.com/clips/pattern

TextBlob:http://textblob.readthedocs.io/en/dev/

Polyglot:https://pypi.python.org/pypi/polyglot

jieba: https://github.com/fxsjy/jieba

八、数据库驱动

mysql-python: https://sourceforge.net/projects/mysql-python/

PyMySQL:https://github.com/PyMySQL/PyMySQL

PyMongo:https://docs.mongodb.com/ecosystem/drivers/python/

pymongo,MongoDB库,访问:https://pypi.python.org/pypi/pymongo/

redis,Redis库,访问:https://pypi.python.org/pypi/redis/

cxOracle,Oracle库,访问:https://pypi.python.org/pypi/cx_Oracle

SQLAlchemy,SQL工具包及对象关系映射(ORM)工具,访问:http://www.sqlalchemy.org/

peewee, SQL工具包及对象关系映射(ORM)工具,访问:https://pypi.python.org/pypi/peewee

torndb,Tornado原装DB,访问:https://github.com/bdarnell/torndb

九、Web

pycurl ———— URL处理工具

smtplib模块 ———— 发送电子邮件

with statement

with statement用于异常处理。

requests模块

requests模块:可以发生http请求,并返回response对象.

什么是urllib

urllib是Python的[URL处理包],可用于访问网页,并且与网页交互。urllib包含了几个模块,如图所示:
在这里插入图片描述

urllib.request

from urllib.request import urlopen

myURL = urlopen("http://194.53.108.5")
print(myURL.read().decode('utf-8'))

打印网页的html源码。

urllib.parse

from urllib.parse import urlparse 
parsedUrl = urlparse('https://www.educative.io/track/python-for-programmers') 
print(parsedUrl) 

打印内容为:URL分为其组成部分,例如所使用的协议方案,网络位置netloc和网页路径path等。

urllib.error

from urllib.request import urlopen, HTTPError, URLError

try:
    myURL = urlopen("http://ww.educative.xyz/")
except HTTPError as e:
    print('HTTP Error code: ', e.code)
except URLError as e:
    print('URL Error: ', e.reason)
else:
    print('No Error.')

打印内容为:URL Error: [Errno -2] Name or service not known

  • 3
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值