因此,我有一个 bash 脚本,它从连接到 NVidea Jetson TK-1 的传感器中以字符串格式在 shell 中输出数据。有什么方法可以运行初始化 bash 脚本的 python 脚本。获取 bash 中的输出数据,将其反馈到可以解析的 python 字符串变量中?我无法编辑 bash 脚本。
谢谢
因此,我有一个 bash 脚本,它从连接到 NVidea Jetson TK-1 的传感器中以字符串格式在 shell 中输出数据。有什么方法可以运行初始化 bash 脚本的 python 脚本。获取 bash 中的输出数据,将其反馈到可以解析的 python 字符串变量中?我无法编辑 bash 脚本。
谢谢
在蟒蛇中:
import subprocess
bash_output = subprocess.check_output('run bash script here')
Subprocess.check_output 将命令发送到 shell,shell 将结果通过管道返回给 python。subprocess.check_output
在此处查看使用示例和文档。