摘要:
def memoize(fn): stored_results = {} @functools.wrap(fn) def memoized(*args): try: # try to get the cached result return stored_results[args] except K 阅读全文
摘要:
一、类型转换#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());三... 阅读全文
摘要:
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 阅读全文
摘要:
摘自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 阅读全文
摘要:
一、修改口令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 阅读全文
摘要:
一、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... 阅读全文
摘要:
一、import logginglogging.basicConfig(filename='...',level=logging.DEBUG)#filename Specifies that a FileHandler be created, using the specified filenam... 阅读全文