根据给定的示例,这是最好的方法:
# test1.py def foo(): print("hellow")
# test2.py from test1 import foo # might be different if in different folder. foo()
但根据标题,使用 os.startfile("path") 这是最好的方法,因为它很小,而且很有效。这将执行指定的文件。我的python版本是3。x+。
os.startfile("path")