How to run Python program?
The first problem that many novice friends encounter is not the data structure of Python, the use of Python class libraries, nor the application of third-party modules and frameworks, but simply "how to run"!To run a python script, there are several ways to achieve it:
1 Run it directly in the command line:
There are different operating system platforms. , mainly windows, linux, unix and other systems.
For windows: In the DOS window, enter python to enter the python running window, and then write code in it.
If it prompts:
#, it means the path is wrong. At this time, you need to use DOS command to switch to the python installation directory, such as me The computer's python is installed in the python directory of the D drive
Now you can enter the python interactive command to write code.
Non-windows systems, such as linux or unix systems, many will automatically install the python operating environment for you. You only need to enter python in the shell directory to see the
python interactive command line environment. .
One advantage of writing code in an interactive command line is that you basically don’t have to enter the print statement deliberately every time. You press Enter. The system will automatically
print the results.
2 Directly save it as a file and run it:
You put the written file into the .py suffix, for example, if you save and write A few lines of python code. The file name saved as test.py is placed in d:\pythoner.
The path of the file is d:\pythoner\test.py. If you want to run test.py, just enter python d:\pythoner\test.py
in dos or enter this directory and run the script: python test.py.
Linux, unix and other other systems are also similar.
3 ide running:
The ulipad editor I use now, you can write the code in it, and then press F5 to run the code, many IDE software It will integrate a built-in python running environment.
You only need to write the program in it, and then directly follow the commands prompted by the editor.