运行 文件在 IDLE window 直接从命令行
Running file in IDLE window from command line directly
因此,我可以在 (Windows) cmd
:
中使用以下命令打开文件以使用 IDLE
进行编辑
python -m idlelib main.py
# not sure if there's a better way to do that
但是,有没有办法 运行 文件并让它的输出直接打开一个新的 IDLE window(或者切换到当前打开的文件)?
是,使用帮助部分中描述的 -r
选项:
USAGE:
idle [-deins] [-t title] [file]*
idle [-dns] [-t title] (-c cmd | -r file) [arg]*
idle [-dns] [-t title] - [arg]*
-h print this help message and exit
-n run IDLE without a subprocess (DEPRECATED,
see Help/IDLE Help for details)
The following options will override the IDLE 'settings' configuration:
-e open an edit window
-i open a shell window
The following options imply -i and will open a shell:
-c cmd run the command in a shell, or
-r file run script from file
-d enable the debugger
-s run $IDLESTARTUP or $PYTHONSTARTUP before anything else
-t title set title of shell window
....
所以,你会这样做:
python -m idlelib -r main.py
因此,我可以在 (Windows) cmd
:
IDLE
进行编辑
python -m idlelib main.py
# not sure if there's a better way to do that
但是,有没有办法 运行 文件并让它的输出直接打开一个新的 IDLE window(或者切换到当前打开的文件)?
是,使用帮助部分中描述的 -r
选项:
USAGE:
idle [-deins] [-t title] [file]*
idle [-dns] [-t title] (-c cmd | -r file) [arg]*
idle [-dns] [-t title] - [arg]*
-h print this help message and exit
-n run IDLE without a subprocess (DEPRECATED,
see Help/IDLE Help for details)
The following options will override the IDLE 'settings' configuration:
-e open an edit window
-i open a shell window
The following options imply -i and will open a shell:
-c cmd run the command in a shell, or
-r file run script from file
-d enable the debugger
-s run $IDLESTARTUP or $PYTHONSTARTUP before anything else
-t title set title of shell window
....
所以,你会这样做:
python -m idlelib -r main.py