1. Interactive programming
What is interactive programming is to enter the python command on the command line. Interactive programming can be started, and the prompt window is as follows:
and also uses the print method of Python3 to print out a string.
2. Scripted Programming
Call the interpreter through script parameters to start executing the script until the script is executed. When the script execution is complete, the interpreter is no longer available.
Let’s write a simple Python script. All Python files will have a .py extension. Copy the following source code to the hello.py file.
What? Don’t know how to create a .py file??
What? Don’t know how to create a .py file? For those who are just getting started. , it is recommended to use the sublime tool (http://www.sublimetextcn.com/) to download and install it at this website (fool-proof installation, all "Next" will be ok). After the installation is complete, click on this small icon to open the editor~~
Click File--New File in the upper left corner to create a new file , enter the following code:
print('hello,Python')
and then press the shortcut key ctrl s to save. Follow the operation as shown below. You will find that the hello.py file has been saved to the D drive.
Place hello.py in the root directory of drive D and run it using the following command:
In the command line mode, run python space hello.py (a file with python execution code), press Enter, (a magical scene will appear~~) and the hello.py I just executed will be executed. hello, Python string written in py file.
python learning network, free online learning python platform, welcome to pay attention!
The above is the detailed content of What are the two programming methods in python?. For more information, please follow other related articles on the PHP Chinese website!