How to run a python script from another python script and get the returned status code?

前端 未结 2 1870
有刺的猬
有刺的猬 2021-01-12 16:20

I\'m relatively new to both Python and bash. However, I am finding Python much more intuitive and easier than bash. I have a few bash scripts I have managed to cobble togeth

2条回答
  •  误落风尘
    2021-01-12 16:36

    Using subprocess module

    master.py

    import subprocess
    retcode = subprocess.call(["/usr/bin/python", "/path/to/test.py"])
    print "Return code of test.py is ", retcode
    

提交回复
热议问题