Вопрос

I am looking to open a Python script in edit mode in IDLE by passing in a directory from another Python script. I understand that I can use os.system to execute idle.py but I then don't know how to pass the appropriate -e parameter and get it to use a specific directory i.e. open something.py in diredtory C:\Python all from the original Python script.

Thanks for your help,

Ben

Это было полезно?

Решение

You can use subprocess.call(). By setting shell = True, the function treats the string as a literal shell command. Modify the paths as you see fit.

import subprocess

subprocess.call(r'C:\Python27\Lib\idlelib\idle.py -e C:\Python27\something.py',
                shell=True)
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top