1.一些错误情况 数据库表中添加索引后确实会让查询速度起飞,但前提必须是正确的使用索引来查询,如果以错误的方式使用,则即使建立索引也会不奏效。即使建立索引,索引也不会生效: 2.其他注意事项 - 避免使用select * - count(1)或count(列) 代替 count(*) - 创建表时尽 Read More
posted @ 2016-10-27 16:56 gege4105 Views(158) Comments(0) Diggs(0) Edit
explain SQL; 在sql语句前面加explain实现“执行计划”的功能。功能是比较准确的显示将要执行这条sql语句的运行状况。 select_simple 是查询类型;table 表名字 possible_keys,key 有可能,真实走的那一列索引 rows 涉及多少条数据 在上述的图片 Read More
posted @ 2016-10-27 15:44 gege4105 Views(125) Comments(0) Diggs(0) Edit
1.关于索引 # 什么是索引 索引是表的目录,在查找内容之前可以先在目录中查找索引位置,以此快速定位查询数据。 #索引的作用 加速查询和约束。 # 为什么索引查询会变快 没创建一个索引会相应的创建一个索引表。索引表是由相应的数据和B-tree数字组成: 30 10 40 5 15 35 66 1 6 Read More
posted @ 2016-10-27 11:59 gege4105 Views(203) Comments(0) Diggs(0) Edit
1.用传统方法计算一个数的二进制 1.只能计算小于2**16的数字 2.用平常数学方法解 2.用特殊字符输出一个指定高和底的空心长方形 结果: 3.用特殊字符实现LED灯效果 结果: Read More
posted @ 2016-10-24 18:27 gege4105 Views(112) Comments(0) Diggs(0) Edit
1.操作mysql的标准流程 上述代码实现了在pycharm下操作mysql的一个标准流程。其中的重点是: #.创建连接 conn = pymysql.connect(host='127.0.0.1', port=3306, user='root', passwd='123', db='t1') # Read More
posted @ 2016-10-24 18:26 gege4105 Views(323) Comments(0) Diggs(0) Edit
1.协程 1 import gevent 2 3 4 def foo(): 5 print('Running in foo') 6 gevent.sleep(0) 7 print('Explicit context switch to foo again') 8 9 10 def bar(): 11 Read More
posted @ 2016-10-18 16:49 gege4105 Views(362) Comments(0) Diggs(0) Edit
1.在多线程和多进程中都有queue。调用方式不同,使用方式一致: 线程中: 进程中: import queueq = queue.Queue(maxsize = 2)q.put(2)q.put(4)q.put(8,block=0) # 默认block为1 即满了就阻塞等待空位,改为0 会full报 Read More
posted @ 2016-10-18 16:15 gege4105 Views(145) Comments(0) Diggs(0) Edit
1.多进程的调用 1.1 multiprocessing调用 运用for循环开启了3个子进程,全都join在主进程中。运行结果: 结果显示:三个字符串同时打印出来。达到了多进程的目的。 1.2类来调用 同时开启了4个进程,但是并没有直接p.run()指令,但是结果显示: 可以看出:run函数是被自动 Read More
posted @ 2016-10-18 15:35 gege4105 Views(160) Comments(0) Diggs(0) Edit
Python3中有两种格式: str:str>>bytes 称为编码(encode)方法有1.re=bytes(“ccc”,“utf8”)2.re=“ccc”.encode(“utf8”)py3中str都是Unicode编码。兼容utf8,三字节表示中文。 bytes:bytes>>str称为解码( Read More
posted @ 2016-10-11 12:31 gege4105 Views(147) Comments(0) Diggs(0) Edit
from http://www.cnblogs.com/yuanchenqi/articles/5938733.html Py 编码的真相 今天让我们一起彻底揭开py编码的真相,包括py2和py3。有同学可能问:以后py3是大势所趋,还有必要了解py2那令人头疼的编码吗?答案是太有必要啦。py2在生 Read More
posted @ 2016-10-11 12:30 gege4105 Views(148) Comments(0) Diggs(0) Edit