Home > Article > Backend Development > Quick Start with Python: Example Code Analysis
If you have already installed the software, if you want to check whether python has been installed on your Windows PC, please search for Python in the start bar or directly enter Python in the command prompt window and press Enter. If Once installed, your installation information will appear.
Python is an interpreted programming language, which means that as a developer, you can write Python in a text editor ( .py) files, and then put these files into the python interpreter for execution.
The way to run a python file on the command line is as follows:
C:\Users\Your Name>python helloworld.py
where "helloworld.py" is the file name of python.
Let's write our first Python file called helloworld.py, which can be done in any text editor.
helloworld.py
print("Hello, World!")
Running the instance
It’s that simple. save document. Open a command line, navigate to the directory where you saved the file, and run:
C:\Users\Your Name>python helloworld.py
Output:
Hello, World!
Congratulations, you have written and executed your first Python program.
To test a small amount of code in python, writing the code in a file is sometimes not the fastest and easiest. It is possible to run Python as a command line.
Type the following on the Windows, Mac or Linux command line:
C:\Users\Your Name>python
From here, you can write any python, including the previous hello world example:
C:\Users\Your Name>python Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> print("Hello, World!")
This will Output "Hello, World!" in the command line:
C:\Users\Your Name>python Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> print("Hello, World!") Hello, World!
At any time, you can exit the python command line interface by typing the following command:
exit()
The above is the detailed content of Quick Start with Python: Example Code Analysis. For more information, please follow other related articles on the PHP Chinese website!