![](/img/trans.png)
[英]Python script works when I run from IDLE but not in command line?
[英]Opening IDLE from another Python script with command line paramteters
我想通過傳入另一個Python腳本的目錄在IDLE中以編輯模式打開Python腳本。 我知道我可以使用os.system
執行idle.py,但是隨后我不知道如何傳遞適當的-e
參數並使其使用特定目錄,即在目錄C:\\ Python中打開something.py原始的Python腳本。
謝謝你的幫助,
本
您可以使用subprocess.call()
。 通過將shell = True
設置shell = True
,該函數將字符串視為文字Shell命令。 根據需要修改路徑。
import subprocess
subprocess.call(r'C:\Python27\Lib\idlelib\idle.py -e C:\Python27\something.py',
shell=True)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.