今天来聊聊62 – 如何为一个线程函数传递参数

当运行一个线程函数时,如何为该函数传递参数

import threading
# 线程函数
def func1(s, fun):
print('正在执行函数func1')
fun(s)
def ff(s):
print(f'ff输出了{s}')
t1 = threading.Thread(target=func1, args=('hello world', ff))
t1.start()

正在执行函数func1

ff输出了hello world

正文完