分类下相关文章
2018-01-25 · 阅读 10165
orator - n. 演讲者 这是一个类似 laravel eloquent 的 python orm 库。 https://github.com/sdispater/orator 使用方法与 eloquent 几乎一致,非常清爽。相比之前用过的 peewee,SQLAlchemy,Django ORM,这个库更简洁明了。 唯一的缺点是,这个项目近期非常不活跃,而且作者对于 pull request 置之不理。 hello world 示例 #!/usr/bin/env python # -*- coding: utf-8 -*- from orator import DatabaseM ...
2018-01-03 · 阅读 12545
核心代码就这么几行,从 Github 上抄的。。。 使用的是 Python 内置的 telnetlib 这个库。 需要注意的是 expect 里的规则是正则,所以判断登录之后修改密码的逻辑一定要将中括号转义。 while result[0] != 5: tn.write("\n") result = tn.expect([ u"酸甜苦辣板".encode("GBK"), u"本日十大衷心祝福".encode("GBK"), u"本日十大热门话题".encod ...
2017-12-19 · 阅读 7405
def time_it(method): def timed(*args, **kw): start_time = time.time() ...
2017-12-19 · 阅读 16183
uuid1 是与机器信息相关的一个 uuid,包含了时间信息,以及机器信息. 分布式存储时使用。 uuid4 则是一个纯随机数,与机器无关, 相重的几率很小。通常生成用户id用这个。 ...
2017-08-19 · 阅读 8080
One of the differences between a great programmer and a bad programmer is that a great programmer adds logging and tools that make it easy to debug the program when things fail. -- Henrik Warne 同一服务的不同功能的日志如何记录 根据 Logging Cookbook 里的解释,可以使用 logging.getLogger("app_name") 创建一个父 logger,然后 ...
2017-06-16 · 阅读 14370
Python 除法运算符 '/' 与 '//' 的区别 >>> 10 / 3 3 >>> 10 // 3 3 >>> 10 / 3.0 3.3333333333333335 >>> 10 // 3.0 3.0 >>> type(10 // 3.0) <type 'float'> 也就是当除数和被除数都是整数的时候,返回结果都是整数。 当除数和被除数至少有一个是浮点数的时候,返回结果都是浮点数。但是, // 的结果的小数部分永远是 0. `Floor division'' is what Py ...
2017-04-03 · 阅读 12217
SQLAlchemy is the Python SQL toolkit and Object Relational Mapper that gives application developers the full power and flexibility of SQL. alchemy 是啥意思 ['ælkɪmɪ] n. 点金术;魔力 最佳教程 官方文档 (推荐下载 PDF 到 kindle 里慢慢看) Essential SQLAlchemy (太旧了,还是看官方文档吧) 使用 SQLAlchemy 之类的 ORM 相对 raw sql 的好处 ORM 可以将数据库存储的数据 ...
2017-04-03 · 阅读 7674
是否可自动化测试是评判程序好坏的唯一标准 注意 需要区分 mock 不同对象的方法, 例如: mock method (被测试类已被实例化) -> MagicMock mock method argument -> MagicMock mock class (被测试类尚未被实例化, 但是需要 mock 其实例化后的指定方法) -> with patch Mock 与 MagicMock 的区别 MagicMock 更灵活一些,官方推荐默认使用 MagicMock. 什么时候使用 patch decorator 由于 module 和 class 是全局的,所以执行完一 ...
2016-04-15 · 阅读 10426
需要验证的问题 如何使用代理 设置代理之后是否对 urllib2 有全局影响 测试程序 api.py # -*- coding: utf-8 -*- import urllib2 def get_rsp(url): response = urllib2.urlopen(url) status_code = response.code content = response.read(300) print "status code: %s" % status_code print "content: %s" ...
2019-07-07 · 阅读 24346
We can become blind by seeing each day as a similar one. -- Paolo Coelho 教程 最佳教程 patch_all 不是一个好主意 gevent.monkey.patch_all() 给所有能打上 patch 的模块打上 gevent.monkey.patch_socket() 只给 socket 模块打上 我觉得最佳的方式是,只针对你需要的模块打 patch, 否则容易造成 gevent 的滥用。 gevent tutorial 称 monkeypatching 为 dark corners of Gevent. 当然 ...
2015-12-12 · 阅读 5655
PyPI PyPI - the Python Package Index 参考文档 第一次提交参考了 How to submit a package to PyPI — Peter Downs 但是感觉这个文档有点旧了,很多地方会报 warning。 官方的流程在这里 Packaging and Distributing Projects — Python Packaging User Guide documentation 官方文档的问题是,更像是个字典,没有流程。这里有一个不错的流程文档 Minimal Structure — Python Packaging Tutorial 本地调试 ...
生活 | 跑步 清单 足球 鲁班 探索 孤独的美食家 驾驶 电视剧 收纳 奶爸 健康 game 电影 周末 |
---|---|
Geek | 健身 Laravel Git Vim MySQL Linux UI Windows SVN 纪录片 管理 Shell 游记 工具 手机 BackboneJS 自建博客 Mac DNS Tornado CDN Django Python AngularJS 理财 前端 Nginx 爬虫 Redis Javascript Browser 浏览器 推广 OAuth CSS PHP Social Networks 安全 运维 创业 杂记 VueJS Android Image IDE Java ReactJS 数据分析 SQLite RESTful 读书笔记 家电 ecshop Vagrant wordpress docker SEO GTD magento mongodb nodejs weex 冷知识 ruby iOS 微信小程序 AI CMS 快应用 backpack 广告联盟 OA 短信 UWP Win CSharp Tampermonkey graphviz 钉钉 WPS 数据字典 微信公众号 Fuchsia Adobe XD SQL Server thinkphp 代码规范 商业模式 Flutter 头痛的问题 serverless 视频制作 国际化 golang 服务器 Kotlin 网站建设 5G 笔记本 图片 spark spring 物联网 InfluxDB 图像识别 postgre rust |
成长的烦恼 | 闲言碎语 待产 不睡觉 写作 程序员 孙心然语录 原则 大鸿语录 |
地球 | 植物 时间 中文 赚钱 国家地理 烟台 一生伏首拜阳明 emoji 弟子规 英文 国际贸易 |