2013年12月30日
摘要: 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 阅读(179) 评论(0) 推荐(0) 编辑
  2013年12月20日
摘要: 一、类型转换#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 阅读(138) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(311) 评论(0) 推荐(0) 编辑
  2013年12月8日
摘要: 摘自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 阅读(388) 评论(0) 推荐(0) 编辑
  2013年12月5日
摘要: 一、修改口令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 阅读(194) 评论(0) 推荐(0) 编辑
  2013年11月27日
摘要: 一、thread(不推荐)1 import thread2 def foo(a):3 print a4 5 thread.start_new_thread(foo,(a))二、threading1 import threading2 class MyThread(threading.Thread):3 # def __init__(self,a):4 # threading.Thread.__init__(self[,name=xxx])5 # self.a=a6 def run(self):7 pass8 thr=MyThre... 阅读全文
posted @ 2013-11-27 16:38 perel 阅读(207) 评论(0) 推荐(0) 编辑
摘要: 一、import logginglogging.basicConfig(filename='...',level=logging.DEBUG)#filename Specifies that a FileHandler be created, using the specified filenam... 阅读全文
posted @ 2013-11-27 11:12 perel 阅读(279) 评论(0) 推荐(0) 编辑
  2013年11月26日
摘要: kkk#coding=utf8if __name__ == '__main__': print "hello world" 阅读全文
posted @ 2013-11-26 16:21 perel 阅读(110) 评论(0) 推荐(0) 编辑