import threading,time
def fn1(x, y, z):
while True:
print("I'm doing sport.")
print('args: %s %s %s' % (x, y, z))
time.sleep(1)
def fn2(a, b, c):
while True:
print("I'm singing.")
time.sleep(1)
if __name__ == '__main__':
# 创建一个线程
th1 = threading.Thread(target = fn1, kwargs = {"x": "hello", "y": "welcome", "z": "to"})
th1.start()
# 创建另一个线程
th2 = threading.Thread(None, fn2, args = ('1', '2', '3'))
th2.start()
![](https://img2024.cnblogs.com/blog/35695/202408/35695-20240826070647288-243310440.jpg)