12 2013 档案
缓存 装饰器
摘要:def memoize(fn): stored_results = {} @functools.wrap(fn) def memoized(*args): try: # try to get the cached result return stored_results[args] except K 阅读全文
posted @ 2013-12-30 14:09 perel 阅读(186) 评论(0) 推荐(0)
c++ 备忘
摘要:一、类型转换#include stringstream ss;ss>i1>>i2;ss.clear();ss>s1;ss.clear();二、string逆序#include reverse(s1.begin(),s1.end());string s(s1.rbegin(),s1.rend());三... 阅读全文
posted @ 2013-12-20 15:32 perel 阅读(147) 评论(0) 推荐(0)
python备忘
摘要:1)列表逆序,字符串逆序l[::-1] l.reverse() #list2)三元操作符x if x>y else y(x>y and [x] or [y])[0]3)阶乘f=lambda n:reduce(lambda x,y:x*y,range(1,n+1))4)sort,sortedsorte 阅读全文
posted @ 2013-12-20 15:24 perel 阅读(331) 评论(0) 推荐(0)
python使用sqlite
摘要:摘自python帮助文档一、基本用法import sqlite3conn = sqlite3.connect('example.db')#conn = sqlite3.connect(':memory:')c = conn.cursor()c.execute('''CREATE TABLE stocks (date text, trans text, symbol text, qty real, price real)''')#NULL,INTEGER,REAL,TEXT,BLOBc.execute("I 阅读全文
posted @ 2013-12-08 23:25 perel 阅读(417) 评论(0) 推荐(0)
mysql 备忘
摘要:一、修改口令mysqladmin -u root password "newpass"mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpass');mysql> use mysql;mysql> UPDATE user SET Password = PASSWORD('newpass') WHERE user = 'root';mysql> FLUSH PRIVILEGES;忘记root口令#/opt/r 阅读全文
posted @ 2013-12-05 09:31 perel 阅读(205) 评论(0) 推荐(0)