Python操作系统()未找到

2024-10-04 03:17:06 发布

您现在位置:Python中文网/ 问答频道 /正文

正在尝试运行一个启动Raspberry Pi相机的文件。 我可以很容易地做到

cd dir

然后呢

./start.sh

所以我尝试用Python代码运行它:

os.system("~/RosPi_Cam_Web_Interface/start.sh")

但它说找不到这个方向。 我做错什么了? 如何更好地使用子流程来实现呢?在


Tags: 文件webosshdirpicd方向
1条回答
网友
1楼 · 发布于 2024-10-04 03:17:06

~由shell展开。您必须调用os.path.expanduser将其扩展到主目录:

import os.path
import system

os.system(os.path.expanduser("~/RosPi_Cam_Web_Interface/start.sh"))

相关问题 更多 >