May 29, 2021 Article blog
Recently, a number of small partners have come to ask how the python script is executed. Today, the W3Cschool editor-in-chief came to share with you a few ways to execute the python script.
The first: scripted programming
Copy the following code to the W3Cschool.py file:
print ("Hello, Python!");
Run the script with the following command:
$ python ./W3Cschool.py hello,python
If you are using Linux or Unix, you can add commands at the beginning of the script to execute the Python script directly like a SHELL script.
Add execution rights to the script:
$ chmod +x hello.py
Get the results of the run:
The second: use IDLE
python has a built-in IDE called IDLE, which runs. C
lick on the file → start using it in a new window. Y
ou can write the python program directly in IDLE, and save it according to F5, such as "W3Cschool.py".
Once saved, the console window automatically outputs all running results.
Third: Use python .exe to execute
Enter the CMD directly in win-R, and enter python to run the python-related code directly.
Python how to run the py file for you to introduce here, I hope to help students.