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()
标签:__,Python,创建,threading,线程,time,print
From: https://www.cnblogs.com/zxhoo/p/17610841.html