python执行shell命令并获取执行后的数据


代码:

import os
 
status = os.popen('bash ~/Desktop/test.sh') # 使用os.popen获取执行后的数据
 
print(status.read())

非常好用

相关