[英]Python USB Serial works in IDLE but not when run as a file
[英]Auto run python file when usb inserted
我有一個運行 Linux 的 Raspberry Pi。 我的計划是我可以在機器人中插入 USB 並運行 python 文件。 我選擇這種方法的原因是它允許輕松編輯和調試腳本。
有沒有辦法在插入 USB 時執行我的文件?
嘗試使用 os.path.exists 來檢測 pendrive 是否在無限循環中,當檢測到時,使用 os.system 在 pendrive 上執行代碼並跳出循環。
查看此鏈接: https : //ubuntuforums.org/showthread.php?t=1648939
看起來您應該考慮編寫一個導航到文件目錄並運行“python yourscript.py”的腳本。 那里有關於讓腳本自動運行的詳細信息。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.