简体   繁体   English

如果可能的话,如何从python.exe窗口中启动Python IDLE;如果没有,怎么使用python.exe?

[英]How to start Python IDLE from python.exe window if possible, and if not, what is python.exe even used for?

I am running Windows 7 currently, and I remember when using Linux at the school computers I was able to type "gedit &" into the terminal for example to open up the gedit text editor. 我目前正在运行Windows 7,记得在学校计算机上使用Linux时,可以在终端中键入“ gedit&”,例如,打开gedit文本编辑器。 I was wondering whether there is a similar process to open IDLE, and for that matter a Python program/script by typing it into the "terminal-equivalent." 我想知道是否有类似的过程来打开IDLE,因此,将Python程序/脚本键入“等效终端”即可。 I'm a complete newbie, so I may be off-base a bit...anyways, so there is this terminal-like program called python.exe, and it seems like it should be able to open Python-related software (like IDLE), and I was wondering 1) what python.exe is for, 2) whether it can be treated like a Linux terminal, and 3) how to do stuff in it. 我是一个完全的新手,所以无论如何我可能会有些失落……因此,有一个名为python.exe的类似于终端的程序,看来它应该能够打开与Python相关的软件(例如IDLE),我想知道1)python.exe的用途是什么,2)是否可以将其视为Linux终端,以及3)如何在其中进行操作。 I've tried various commands and I get a syntax error for virtually everything. 我尝试了各种命令,并且几乎所有内容都出现语法错误。 Much appreciated! 非常感激!

python.exe is the Python interpreter. python.exe是Python解释器。 All of your Python programs are executed with it. 您所有的Python程序都将与其一起执行。 If you run it in the console, you will get an interactive prompt: 如果您在控制台中运行它,您将收到一个交互式提示:

C:\> python
Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

If you give it a Python program, it will run it: 如果您给它一个Python程序,它将运行它:

C:\> python myprog.py

You can also ask it to run an importable module: 您也可以要求它运行可导入模块:

C:\> python -m modulename

You can run IDLE this way: 您可以通过以下方式运行IDLE:

C:\> python -m idlelib.idle

Yes you can start libraries like Idle, you need to import idlelib: 是的,您可以启动像Idle这样的库,您需要导入idlelib:

import idlelib.idle

Alternatively, to start idle from terminal without getting into python.exe shell first, you can do python.exe -m idlelib.idle assuming that idlelib is in your PYTHONPATH 另外,要从终端启动空闲而不先进入python.exe shell,可以假设python.exe -m idlelib.idle处于PYTHONPATH中,

The python.exe, is just like the shell in IDLE, is mainly used for quick experimentation with algorithms you want to try or testing library calls or language features, when you don't want to open a new file for that purpose. python.exe就像IDLE中的shell一样,主要用于快速尝试使用您想尝试的算法,或者在您不想为此目的打开新文件时测试库调用或语言功能。 There are similarities with Linux shells like bash, but python's shell are heavily oriented for aiding programming while Linux shell are heavily oriented for starting up other programs. 它与Linux外壳(如bash)有相似之处,但是python的外壳在很大程度上是为了辅助编程,而Linux外壳在很大程度上是为了启动其他程序。 While you can start other programs in python's shell using subprocess.Popen and while bash do have it's own scripting language, they are very different. 虽然您可以使用subprocess.Popen在python的外壳中启动其他程序,而bash确实拥有自己的脚本语言,但它们却大不相同。

python.exe Python,特别是python解释器。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM