代码是这样的:
os.execlp('python', 'python', 'child.py', #other args#) # this works
os.execlp('python', 'child.py', #other args#) # this doesn't work
我读了这个问题:execlp() in python
但我还是很困惑。答案说:
第一个参数是要执行的程序(在 PATH 上找到)。其余的是程序的 sys.argv 参数。
但是,如果我运行:python child.py 1 2 3并且sys.argv这个过程的 将是["child.py", "1", "2", "3"],其中python不存在。那我为什么要添加python作为的第二个参数os.execlp呢?