import time, functools
def performance(unit):
def dec_per(f):
@functools.wraps(f)
def fn(*args,**kw):
t1=time.time()
fx=f(*args,**kw)
t2=time.time()
def performance(unit):
def dec_per(f):
@functools.wraps(f)
def fn(*args,**kw):
t1=time.time()
fx=f(*args,**kw)
t2=time.time()
2015-09-15
import os.path
from os.path import isdir,isfile
print isdir(r'/data/webroot/resource/python')
print isfile(r'/data/webroot/resource/python/test.txt')
from os.path import isdir,isfile
print isdir(r'/data/webroot/resource/python')
print isfile(r'/data/webroot/resource/python/test.txt')
2015-09-15
f1, f2, f3 = count() #调用count()时for 3次循环完成,fs里装的是[f, f, f]
f1() #f() = i*i return时 i 已经循环完成为3
f1() #f() = i*i return时 i 已经循环完成为3
2015-09-15
被自己的无知深深刺痛……
def __cmp__(self, s):
if self.score>s.score:
return -1
elif self.score<s.score:
return 1
elif self.name<s.name:
return -1
elif self.nae>s.name:
return 1
else:
return 0
def __cmp__(self, s):
if self.score>s.score:
return -1
elif self.score<s.score:
return 1
elif self.name<s.name:
return -1
elif self.nae>s.name:
return 1
else:
return 0
2015-09-14
return r'["Tim", "Bob", "Alice"]'
json.read()要读取RAW STRING
json.read()要读取RAW STRING
2015-09-14