在 Python 中,start() 函数通常与线程(threading)模块一起使用
import threadingdef my_function(): print("This is a new thread.")# 创建一个新的线程对象my_thread = threading.Thread(target=my_function)# 启动新线程my_thread.start()# 等待新线程完成my_thread.join()print("Main thread finished.")在这个例子中,我们首先导入了 threading 模块。然后定义了一个名为 my_function 的简单函数,该函数将在新线程中运行。接下来,我们创建了一个新的 Thread 对象,并将 my_function 作为目标参数传递给它。最后,我们调用 start() 方法来启动新线程,并使用 join() 方法等待新线程完成。主线程将在新线程完成后继续执行。




