Python第三方库安装与卸载方法
在安装方面,本人还是遵从把代码拿到本地的原则(不使用easy_install方式),这样可以解决因为版本不兼容导致的各种匪夷所思问题发生。
安装
python setup.py install --record file.txt
卸载
- Windows平台
For /F %f in (file.txt) Do del %f
- Linux平台
cat file.txt |xargs rm -rf
在安装方面,本人还是遵从把代码拿到本地的原则(不使用easy_install方式),这样可以解决因为版本不兼容导致的各种匪夷所思问题发生。
python setup.py install --record file.txt
For /F %f in (file.txt) Do del %f
cat file.txt |xargs rm -rf
用py写了一个获取手机所在地区的工具。哈哈,纯当练习之用。
#####phone.txt内容####
11位手机
11位手机
…
#######################
python自带的解析HTML很是复杂,从Google搜索中,发现BeautifulSoup这个第三方库在解析HTML轻便很多,几乎与jQuery选择器一样好用。
而且BeautifulSoup官方文档还有中文版 🙂
官方说明很详细,如果大家有要使用python解析HTML时,推荐用BeautifulSoup试试。
这里我举两个在代码用的例子:
刚好有个要爬国内某大型网站图片库的需求(国内网站中有海量图片库的网站屈指可数哦),索性就用python练练手,也很久不写了。试试
思路看代码就好,某网站地址我用a_website过滤,你懂的 🙂
python 环境:ActivePython 2.7.2.5
下载图片需要wget,没有的请自行下载。
被官方参考误解:http://webpy.org/cookbook/custom_notfound.zh-cn
不要使用notfound()方法就是了。
# coding:utf-8 import web urls = ( '/', 'index' ) app = web.application(urls, globals()) render = web.template.render('templates/') def my_notfound(): return web.notfound(""" <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>pctools</title> </head> <body> 404 </body> </html> """) web.webapi.notfound = my_notfound app = web.application(urls, globals()) if __name__ == '__main__': app.run()