三個(gè)函數(shù)
def evaluate(s):
try:
return eval(s)#eval()函數(shù)用來(lái)執(zhí)行一個(gè)字符串表達(dá)式,并返回表達(dá)式的值
except:
error('evalutate error:%s'%s)
def error(s):
print(s)
if const.DEBUG:#const.py里設(shè)置為T(mén)RUE
sys.exit(-1)
def multiproc(func, l, core = 4):
pool = Pool(core)
ret = pool.map(func, l)#對(duì)l里的每一個(gè)進(jìn)行func操作,返回列表
pool.terminate()
return ret