多线程

def sing():
	while True:
		print("我在唱歌")
		time.sleep(1)
def dance(msg):
	while True:
		print(msg)
		time.sleep(1)
 
sing_thread = threading.Thread(target = sing)
dance_thread = threading.Thread(target = dance, args=("我在跳舞", ))
dance_thread2 = threading.Thread(target = dance, kwargs={"msg": "我在跳舞"})
sing_thread.start()
dance_thread.start()
dance_thread2.start()
>>> import threading
>>> threadObj = threading.Thread(target=print, args=['Cats', 'Dogs', 'Frogs'], kwargs={'sep': ' & '})
>>> threadObj.start()
Cats & Dogs & Frogs
# 这行代码最终会调用 print()函数,将它的返回值(print()的返回值总是无)作为 target 关键字参数。
threadObj = threading.Thread(target=print('Cats', 'Dogs', 'Frogs', sep=' & '))
# Wait for all threads to end.
for downloadThread in downloadThreads:
    downloadThread.join()