后浪云Python教程:python怎么shell脚本运行

python中运行shell脚本的方法:

1.首先编写一个shell脚本

hello.sh

#!/bin/bash
echo "hello world!"
exit 2

2.在Python中运行shell脚本

下面的512是返回的状态码,如果eixt 0时则返回的是0.

THE END