簡體   English   中英

找不到python os.system()

[英]Python os.system() not found

嘗試通過Raspberry Pi相機運行文件。 我可以輕松做到

光盤目錄

接着

./start.sh

所以我試圖在Python代碼中運行它:

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

但是它說找不到該目錄。 我究竟做錯了什么? 子流程如何做會更好呢?

~由外殼擴展。 您必須調用os.path.expanduser將其擴展到主目錄:

import os.path
import system

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM