Run the python program and the python Program
1. Run the python program in windows
1) run the python script from the doscommand line
Use the pythoninterpreter to execute the pythonscript. In Windows, the pythoninterpreter is python.exe, and my python file is installed in D: \ Python27. You can see the python interpreter in this directory.
The complete command should be:
Python interpreter. py file
The interpreter and The py file both contain the complete path. The interpreter path is indicated in environment variables after IDLE is installed in windows. Therefore, you only need:
Python. py file (full path)
For example, place the hello. py file in the D: \ Python27 \ code folder and run the following command:
Python D: \ Python27 \ code \ hello. py
Alternatively, run the following command in the Directory D: \ Python27 \ code where the hello file is located:
Python hello. py
2) edit the running program in the integrated development environment
In IDLE, edit the file: new window, save, and execute.
3) double-click to run
In windows, you can double-click the. py file to run it.
2. Run the python program in Linux.
1) write and run the code in IDLE, just like in windows.
2) run the program in the command line, which is similar to that in DOS. Enter the directory where the. py file is located and run it with the python Interpreter:
3) make the script run like a normal program
Specify the location of the python interpreter in the first line of the. py file: Add:
#! /Usr/bin/env python
You can directly use./hello. py to execute the program in the directory where the. py file is located:
Summary:
This section describes how to run python programs in windows and Linux.