简体   繁体   中英

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. 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." 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. I've tried various commands and I get a syntax error for virtually everything. Much appreciated!

python.exe is the Python interpreter. All of your Python programs are executed with it. 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:

C:\> python myprog.py

You can also ask it to run an importable module:

C:\> python -m modulename

You can run IDLE this way:

C:\> python -m idlelib.idle

Yes you can start libraries like Idle, you need to import 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

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. 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. 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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