简体   繁体   English

如何使用 CMD 提示在 IDLE 中运行 python 脚本

[英]How to run a python script in IDLE using CMD prompt

I am wondering if there is a way to open a python script in IDLE run mode, (the equivalent of opening it with idle.exe {path} and pressing F5) or set it up so that if a.py file is open with IDLE it automatically runs it.我想知道是否有办法在 IDLE 运行模式下打开 python 脚本(相当于用 idle.exe {path} 打开它并按 F5)或设置它以便如果 a.py 文件以 IDLE 打开它会自动运行它。

#Opens without IDLE GUI
python {path}
#Opens in IDLE, but in editor mode
@ECHO OFF
idle.exe {path_to_idle}
# Running script.py in idle
idle.exe -r script.py

You might consider using:您可以考虑使用:

# Inspect interactively after running script (see "python --help" from cmd)
python -i script.py

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Python脚本可在IDLE中运行,但从CMD或Eclipse运行时不起作用 - Python script working in IDLE, but not working when run from CMD or Eclipse 如何在 cmd 中运行 python 脚本 - how to run python script in cmd 运行另一个没有弹出式cmd提示符的python脚本,而不是顺序 - Run another python script without a popup cmd prompt and not in a sequence Python - 如何从 IDLE 与命令提示符运行模块 - Python - How to run module from IDLE vs. command prompt 如何在 IDLE 上运行特定于命令提示符的 python 库? - How do I run python libraries specific to command prompt on IDLE? UnicodeEncodeError:脚本在Spyder和IDLE上运行,但不在cmd提示符下运行 - UnicodeEncodeError: Script runs on Spyder and IDLE, yet not on cmd prompt 如何打开命令提示符以及使用python脚本运行的命令? - How to open a command prompt along with a command to run using a python script? 为什么这在Python IDLE shell中有效,但在我从命令提示符下作为Python脚本运行时却没有? - Why does this work in the Python IDLE shell but not when I run it as a Python script from the command prompt? 如何使用Python对IDLE交互式提示进行分区? - How would I partition the IDLE interactive prompt using Python? 使用python脚本在命令提示符下运行命令 - Run commands in command prompt using python script
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM