How to run code program in python

Release: 2019-07-04 11:04:07
Original
43526 people have browsed it

How to run code program in python

1. Using the Python interpreter:

1. When installing python, there will usually be an interactive interpreter, where we can directly write and run

How to run code program in python

#2. But if we turn it off, the code we just wrote will be lost. At this point, we create a new text document, write print 'hello world', and then rewrite the file name as: hello.py. Note that the suffix is ​​py, and your computer must display the suffix to see it. Then, we open the interpreter and open the py we just wrote through file->open

How to run code program in python

3. After opening, the following interface will be displayed, which is the code we just wrote

How to run code program in python

4. At this time, you can click Run->run module, or press F5 directly to run the code, as shown in the figure below, the operation is successful and the result is printed

How to run code program in python

2. Run through the command line

As shown in the figure below, there is a hello.py file

How to run code program in python

We directly enter cmd in the file address bar above and hit Enter

How to run code program in python

You can see that it will be directly located in the corresponding directory

How to run code program in python

We enter python hello.py, we can run the program

How to run code program in python

or we can run hello.py directly

How to run code program in python

3. Double-click to run:

You can directly double-click to run, but the window will flash by. What should I do?

Add the following code:

raw_input('press ')

At this time, we double-click the program directly and find that the cmd box has not disappeared. The interface will disappear only after you press the Enter key

How to run code program in python

For more Python-related technical articles, please visit the Python Tutorial column to learn!

The above is the detailed content of How to run code program in python. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!