import threading
def thread_job():
print("This is an added Thread, number is %s" % threading.current_thread()) # 线程的名字
def main():
add_thread = threading.Thread(target=thread_job) # 添加的线程
add_thread.start() # 线程开始
if __name__=='__main__':
main()
以上的代码 主要是介绍了 如何创建一个线程 和怎样让线程开始。
其中 target=thread_job 是说明 让自定义的这个线程做什么工作的。