python 线程池 ThreadPoolExecutor简单案例

###导入

from concurrent.futures import ThreadPoolExecutor as tpe

import time

####初始化线程

tpe = tpe(10)

###打印指定信息

# site : 打印的主题

# masg : 打印的信息

def print_custom_masg(masg, site="", pyn='nothing', option='nothing'):

print('【brush:' + str(site) + '】【' + pyn + '】【' + option + '】: ' + str(masg))

tpe.submit(print_custom_masg,'1','2','3','4')

总结:

print_custom_masg: 为方法名

,'1','2','3','4' : 为 print_custom_masg 中的参数,和普通调用 print_custom_masg 方法传参 类似

猜你喜欢

转载自blog.csdn.net/qq_29499107/article/details/85238812