Running bash script from within python

前端 未结 7 893
死守一世寂寞
死守一世寂寞 2020-11-27 11:50

I have a problem with the following code:

callBash.py:

import subprocess
print \"start\"
subprocess.call(\"sleep.sh\")
print \"end\"         


        
7条回答
  •  庸人自扰
    2020-11-27 11:58

    If chmod not working then you also try

    import os
    os.system('sh script.sh')
    #you can also use bash instead of sh
    

    test by me thanks

提交回复
热议问题