import os import sys import time program = "python3" print("Process calling") arguments = ["xxxxxx.py"] os.execvp(program, (program,) + tuple(arguments)) print("Good Bye!!") time.sleep(5)
xxxxxx.py
print("hahhaha")
python3 code.py
macname@MacdeMBP files % python3 test.py
Process calling
hahhaha
macname@MacdeMBP files %
原文:https://www.cnblogs.com/sea-stream/p/14181825.html