1 Running a python program under Windows
1) Run the Python script from the DOS command line
Using Python interpreter to execute Python script, under Windows Python interpreter is python.exe, my Python file is installed in D:\Python27, in this directory you can see the Python interpreter.
The complete command should be:
Python interpreter. py file
Both the interpreter and the Py file contain the full path. The interpreter path is indicated in the environment variable since idle is installed in the Windows environment. So just run:
Python. py file (full path)
For example: hello.py files are placed under the D:\Python27\code folder and run as follows:
Python D:\Python27\code\hello.py
or advanced to the directory where Hello files are located D:\Python27\code, and then run:
Python hello.py
2) Edit the running program in the integrated development environment
Edit the file in idle: New window, save, execute.
3) Double-click Run
Under Windows, A. py file can be run directly by double-clicking.
2,linux Running the Python program
1) write code and run in idle, just like windows
2) Run the program in the command line, similar to DOS, enter the directory where the. py file is located, executed with the Python interpreter:
3) Let the script run like a normal program
Specify the location of the Python interpreter in the first line of the. py file: Plus:
#!/usr/bin/env python
You can use the./hello.py to execute the program directly in the same directory as the. py file:
Summarize:
Describes how to run Python programs under Windows and Linux.
Run a python program