python
啦啦啦小画家
这个作者很懒,什么都没留下…
展开
-
python 单例模式
单例模式是一种对象创建型模式,确保某一个类只有一个实例,而且自行实例化并向整个系统提供这个实例,这个类称为单例类。代码: # 实例化一个单例class Singleton(object): __instance = None def __new__(cls, age, name): # 如果类属性__instance的值为None, ...转载 2019-01-18 09:45:46 · 192 阅读 · 0 评论 -
random two numbers add and sub
#!/usr/bin/env pythonfrom operator import add, subfrom random import randint, choiceops = {'+': add, '-': sub}MAXTRIES = 2def doprob(): op = choice('+-') nums = [randint(1, 10) for i ...原创 2019-03-12 14:07:23 · 123 阅读 · 0 评论 -
lambda function
x = 10def foo(): y = 5 bar = lambda z: x + y print bar(y) y = 8 print bar(y)foo()原创 2019-03-12 14:08:34 · 327 阅读 · 0 评论 -
数据筛选及转成CSV文件,保存后并在Excel文档编辑操作
comptest.log file source:CSV summary:Algorithm,Test_type,Using_engine_compression,Using_engine_decompression,Deflate_buffering_enabled,Inflate_buffering_enabled,Compression_Level,Chunk_Size,Pollin...原创 2019-03-21 11:41:20 · 565 阅读 · 0 评论 -
pyc convert to py file
# -*- coding: utf-8 -*-# requirements: pip install uncompyle6from os.path import splitext, isdirfrom os import listdir, system, mkdirif __name__ == '__main__': if system('uncompyle6 -h >...原创 2019-03-13 09:20:20 · 362 阅读 · 0 评论 -
Python PEP8 check tool
检查工具透过可以官方提供的工具pycodestyle来检查脚本代码是否符合PEP 8安装pycodestyle$ pip install pycodestyle检查脚本$ pycodestyle check_test.py(or keys.json)check_test.py:1:10: E231 missing whitespace after ','check_tes...原创 2019-04-10 14:57:21 · 364 阅读 · 0 评论 -
mysql 数据库
一、基础规范(1)必须使用InnoDB存储引擎解读:支持事务、行级锁、并发性能更好、CPU及内存缓存页优化使得资源利用率更高(2)必须使用UTF8字符集解读:万国码,无需转码,无乱码风险,节省空间(3)数据表、数据字段必须加入中文注释解读:N年后谁tm知道这个r1,r2,r3字段是干嘛的(4)禁止使用存储过程、视图、触发器、Event解读:高并发大...转载 2019-04-23 15:14:10 · 181 阅读 · 0 评论