What is the way to run a python script

Release: 2019-07-03 10:13:40
Original
6730 people have browsed it

What is the way to run a python script

Under Windows:

Output through script
Use a text editor to write a script file and name it hello.py, enter the folder where this file is located in command line mode, enter python hello.py to execute Python in interactive mode. In this mode, there is no need to create a script file, just write the corresponding Python statement directly in the interactive mode of the Python interpreter.

Enter the command line mode, enter: python in the command line mode to enter the interactive mode of Python

What is the way to run a python script

In the interactive mode, output: Hello World!

What is the way to run a python script

Under Linux:

Enter python directly in the terminal. If python3 is installed, enter the corresponding version of the Python interactive environment according to the name of the soft connection you created. For example, I use python3 to establish a soft connection, and enter python3 here.

What is the way to run a python script

Output in interactive mode: Hello World!

What is the way to run a python script

Output via script

Through a text editor, Write a script file and name it hello.py. Enter python hello.py in the command line mode.

The command is as follows: What is the way to run a python script

[Vicky@localhost code]$ touch hello.py
[Vicky@localhost code]$ vi hello.py 
[Vicky@localhost code]$ python3 hello.py 
Hello World!
Copy after login

For more Python related technical articles, please visit
Python Tutorial

column to learn!

The above is the detailed content of What is the way to run a python script. 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