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

63 - 在线程中如何创建和使用全局对象

发布了208 篇原创文章 · 获赞 249 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/qq_29339467/article/details/104804809
62
62-