Run the python program and the python Program

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.