因此,我可以在 (Windows) cmd
中使用以下命令使用 IDLE
打开文件进行编辑:
python -m idlelib main.py
# not sure if there's a better way to do that
但是,有没有一种方法可以运行该文件并使其输出直接打开一个新的 IDLE 窗口(或者切换到当前窗口,如果有打开的窗口)?
最佳答案
是的,使用帮助部分中描述的-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
关于python - 直接从命令行在 IDLE 窗口中运行文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52612511/