赵走x博客
网站访问量:151579
首页
书籍
软件
工具
古诗词
搜索
登录
13、音乐篇
12、mobi 阅读器推荐
11、软著申请字体要求
精品推荐:10、面试资料
精品推荐:9、Flutter优秀库
精品推荐:8、百度网盘搜索方式
精品推荐:7、数据接口
精品推荐:6、书籍资料篇
精品推荐:5、python实用篇
4、前端常用框架篇
精品推荐:3、python爬虫篇
精品推荐:2、人工智能篇
谷歌搜索gitbook的方法
精品推荐:1、生活实用篇
常见文件的mime类型
精品推荐:5、python实用篇
资源编号:75732
精品推荐
热度:122
python实用篇
[ 1、 ](https://hellogithub.com/periodical/volume/35/#spug)[spug](https://github.com/openspug/spug) 使用 Python+Vue 实现的开源运维平台,前后端分离方便二次开发。该项目基于 Docker 镜像发布部署,方便安装和升级。支持运维常见功能:主机管理、任务计划管理、发布部署、监控告警等 [2、langid:](https://github.com/saffsd/langid.py) 用于识别输入文本数据所属的语种,目前支持 97 种语言识别。示例代码: ``` import langid text1 = "I am a coder and love data mining" text2 = "请注明作者和出处并保留声明和联系方式" print langid.classify(text1) print langid.classify(text2) # ('en', 0.9999957874458753) # ('zh', 1.0) ``` [3、reddit](https://hellogithub.com/periodical/statistics/click/?target=https://github.com/reddit/reddit):[reddit.com](https://www.reddit.com/) 网站的源码,通过这个项目,可以学习 Python 在构建大型项目中的使用、项目结构、代码风格、Python 技巧的使用方法等。[安装教程](https://github.com/reddit/reddit/wiki/Install-guide)  [4、PyMySQL](https://hellogithub.com/periodical/statistics/click/?target=https://github.com/PyMySQL/PyMySQL):纯 Pyton 写的 MySQL 库,纯 Python 的好处就是可以运行在任何装有 Python 解释器(CPython、PyPy、IronPython)的平台上。相对于 [MySQLdb](https://github.com/farcepest/MySQLdb1) 性能几乎一样,使用方法也一样,但是 **PyMySQL 安装方法极其简单**——`pip install PyMySQL`,PyMySQL 使用示例代码: ``` # 下面为例子需要的数据库的建表语句 CREATE TABLE `users` ( `id` int(11) NOT NULL AUTO_INCREMENT, `email` varchar(255) COLLATE utf8_bin NOT NULL, `password` varchar(255) COLLATE utf8_bin NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ; ``` ``` # -*- coding: utf-8 -*- import pymysql.cursors # 连接数据库 connection = pymysql.connect(host='localhost', user='user', password='passwd', db='db', charset='utf8mb4', cursorclass=pymysql.cursors.DictCursor) try: with connection.cursor() as cursor: # 创建一个新的纪录(record) sql = "INSERT INTO `users` (`email`, `password`) VALUES (%s, %s)" cursor.execute(sql, ('webmaster@python.org', 'very-secret')) # 连接不会自动提交,所以你想下面要调用 commit 方法,存储对数据库的改动 connection.commit() with connection.cursor() as cursor: sql = "SELECT `id`, `password` FROM `users` WHERE `email`=%s" cursor.execute(sql, ('webmaster@python.org',)) # 获取一条的纪录(record) result = cursor.fetchone() print(result) # 结果输出:{'password': 'very-secret', 'id': 1} finally: connection.close() # 操作完数据库一要记得调用 close 方法,关闭连接 ``` [5、PTVS](https://hellogithub.com/periodical/statistics/click/?target=https://github.com/Microsoft/PTVS):Visual Studio 下的 Python 开发插件 [6、flask-limiter](https://hellogithub.com/periodical/statistics/click/?target=https://github.com/alisaifee/flask-limiter):一个 Flask 的扩展库,它可以根据访问者的 IP 限制其访问频率、次数等。示例代码如下: ``` from flask import Flask from flask_limiter import Limiter from flask_limiter.util import get_remote_address app = Flask(__name__) limiter = Limiter( app, key_func=get_remote_address, global_limits=["2 per minute", "1 per second"], ) @app.route("/slow") @limiter.limit("1 per day") def slow(): return "24" @app.route("/fast") def fast(): return "42" @app.route("/ping") @limiter.exempt def ping(): return 'PONG' app.run() ``` [7、ngrok](https://hellogithub.com/periodical/statistics/click/?target=https://github.com/inconshreveable/ngrok):一个十分方便、好用的内网穿透工具,它可以把本地某个端口的服务,通过一个安全隧道,映射到公网的一个地址。同时它提供了一个 Web 页面,展示了每个请求、响应的所有信息,便于调试本地的程序。基本的使用方法如下: ``` ngrok 协议 本地服务监听的端口 ngrok http 8000 创建成功会返回公网地址,然后通过该地址就可以访问到本地的服务。 本地访问 http://localhost:4040,就可以查看关于每个请求、响应的相关数据 ```  [8、glances](https://hellogithub.com/periodical/statistics/click/?target=https://github.com/nicolargo/glances):一个可以让你**一目了然**你的系统情况(类 (h)top)的工具,它界面友好,安装方便:`pip install glances`  9、[locust](https://hellogithub.com/periodical/statistics/click/?target=https://github.com/locustio/locust):模拟用户行为的[负载测试](http://blog.csdn.net/kerryzhu/article/details/3515714)工具,包含友好的 Web 页面,如下图: [](https://raw.githubusercontent.com/521xueweihan/img/master/hellogithub/10/img/locust-show-min.png) 10、[500lines](https://hellogithub.com/periodical/statistics/click/?target=https://github.com/aosabook/500lines):(英文)用少于 500 行的 Python 代码,你可以写出什么东西?相信你看完这个项目,会学到很多(每个项目的作者都是业内大神写的)。[中文翻译版(未翻译完)](https://github.com/HT524/500LineorLess_CN) 11、[ngxtop](https://hellogithub.com/periodical/statistics/click/?target=https://github.com/lebinh/ngxtop):解析 nginx 访问日志并格式化输出有用的信息,可以用来实时了解你的服务器正在发生的情况。安装命令 `pip install ngxtop`,输出示例如下: ``` $ ngxtop running for 411 seconds, 64332 records processed: 156.60 req/sec Summary: | count | avg_bytes_sent | 2xx | 3xx | 4xx | 5xx | |---------+------------------+-------+-------+-------+-------| | 64332 | 2775.251 | 61262 | 2994 | 71 | 5 | Detailed: | request_path | count | avg_bytes_sent | 2xx | 3xx | 4xx | 5xx | |------------------------------------------+---------+------------------+-------+-------+-------+-------| | /abc/xyz/xxxx | 20946 | 434.693 | 20935 | 0 | 11 | 0 | | /xxxxx.json | 5633 | 1483.723 | 5633 | 0 | 0 | 0 | | /xxxxx/xxx/xxxxxxx | 3624 | 7830.236 | 3621 | 0 | 3 | 0 | | /static/js/minified/utils.min.js | 3031 | 1781.155 | 2104 | 927 | 0 | 0 | ``` 12、[algorithms](https://hellogithub.com/periodical/statistics/click/?target=https://github.com/keon/algorithms):基本算法、数据结构的 Python 实现 ``` . ├── array │ ├── circular_counter.py │ └── ... ├── backtrack │ ├── anagram.py │ └── ... ├── bfs │ ├── shortest_distance_from_all_buildings.py │ └── word_ladder.py ├── bit │ ├── count_ones.py │ └── ... │ └── traversal.py └── 等等 ``` 13、[searx](https://hellogithub.com/periodical/statistics/click/?target=https://github.com/asciimoo/searx):分分钟打造一个聚合的搜索引擎,使用简单,部署方便。拓展方便,基于插件式的管理。[演示地址](https://searx.me/) 14、[grequests](https://hellogithub.com/periodical/statistics/click/?target=https://github.com/kennethreitz/grequests):Rquests + Gevent 让异步 HTTP 变得简单、人性化。示例代码: ``` >>> import grequests >>> def exception_handler(request, exception): ... print "Request failed" >>> reqs = [ ... grequests.get('http://httpbin.org/delay/1', timeout=0.001), ... grequests.get('http://fakedomain/'), ... grequests.get('http://httpbin.org/status/500')] >>> grequests.map(reqs, exception_handler=exception_handler) Request failed Request failed [None, None,
] ``` 15、[certbot](https://hellogithub.com/periodical/statistics/click/?target=https://github.com/certbot/certbot):免费的自动启用和部署 HTTPS 的工具,让你的网站开启 HTTPS 变得简单快捷。在部署教程页面选择服务器的操作系统和 Web 服务器,之后根据给出的步骤一步步的执行命令就行了,[部署教程](https://certbot.eff.org/) [](https://raw.githubusercontent.com/521xueweihan/img/master/hellogithub/14/img/cerbot-show-min.png) 16、[pdir2](https://hellogithub.com/periodical/statistics/click/?target=https://github.com/laike9m/pdir2):Python 程序员需要一个更好的 `dir()` —— 以更加友好的显示 `dir()` 输出的结果 [](https://raw.githubusercontent.com/521xueweihan/img/master/hellogithub/14/img/pdir2.gif) 17、[syncPlaylist](https://hellogithub.com/periodical/statistics/click/?target=https://github.com/Denon/syncPlaylist):在网易云音乐与 QQ 音乐之间同步歌单。易于使用、配置方便、代码简单,用到的技术:`requests` + `beautifulsoup` 以及 `selenium` + `phantomjs` 18、[simiki](https://hellogithub.com/periodical/statistics/click/?target=https://github.com/tankywoo/simiki):一个简单的个人 Wiki 框架,便于快速搭建 Wiki 页。使用 Markdown 书写 Wiki, 生成静态 HTML 页面。Wiki 源文件按目录分类存放, 方便管理维护。[中文文档](http://simiki.org/zh-docs/) 19、[pyecharts](https://hellogithub.com/periodical/statistics/click/?target=https://github.com/chenjiandongx/pyecharts):Echarts+Python 实现的一个用于生成 Echarts 图表的类库 [](https://raw.githubusercontent.com/521xueweihan/img/master/hellogithub/17/img/pyecharts.gif) 20、faker:用于生成假数据的库,支持多种语言,你值得拥有。示例代码: ``` fake.address() # '辽宁省雪市静安廉街b座 998259' fake.street_address() # '巢湖街U座' fake.building_number() # 'x座' fake.city_suffix() # '市' fake.latitude() # Decimal('-0.295126') fake.province() # '湖北省' ``` 21、[binlog2sql](https://hellogithub.com/periodical/statistics/click/?target=https://github.com/danfengcao/binlog2sql):从 MySQL binlog 解析出你要的 SQL。根据不同选项,提供如下功能 * 数据快速回滚,[闪回原理与实践](https://github.com/danfengcao/binlog2sql/blob/master/example/mysql-flashback-priciple-and-practice.md) * 主从切换后新 master 丢数据的修复 * 从 binlog 生成标准SQL,带来的衍生功能 22、[pandas-tutorial](https://hellogithub.com/periodical/statistics/click/?target=https://github.com/hangsz/pandas-tutorial):这套 pandas 教程包含从初级到进阶的内容,适合初学者和希望进阶建立知识体系的数据科学从业者阅读。作者还在持续更新高级内容,你值得拥有 23、[pysheeet](https://hellogithub.com/periodical/statistics/click/?target=https://github.com/crazyguitar/pysheeet):Python 速查表,[在线阅读](https://www.pythonsheets.com/) 24、[robobrowser](https://hellogithub.com/periodical/statistics/click/?target=https://github.com/jmcarp/robobrowser):提供多种模拟操作网页的库,比如获得网页内容、访问链接、点击按钮、填充并提交表单、上传文件。使用简单、API 友好。适用于想要通过脚本流程化操作,某些未提供这些操作接口的场景,示例代码如下: ``` # 上传文件 from robobrowser import RoboBrowser # Browse to a page with an upload form browser = RoboBrowser() browser.open('http://cgi-lib.berkeley.edu/ex/fup.html') # Find the form upload_form = browser.get_form() upload_form #
# Choose a file to upload upload_form['upfile'] #
upload_form['upfile'].value = open('path/to/file.txt', 'r') # Submit browser.submit(upload_form) ``` 25、[ItChat](https://hellogithub.com/periodical/statistics/click/?target=https://github.com/littlecodersh/ItChat):开源的微信个人号SDK,提供了丰富的功能。从而使得 Python 调用微信、发送消息、传输文件等操作只需要编写极少的代码,示例代码如下: ``` import itchat itchat.auto_login() itchat.send('Hello, filehelper', toUserName='filehelper') ```