Python Learning (1), Python Learning (
Installation and Use
1. Take 2.7.6 as an Example
Installation path: D: \ Program Files (x86) \ Python27 \
After the installation is complete, open the software. If the prompt is: 'python' is not an internal or external command, or a program or batch file that can be run.
You need to manually add environment variables.
2. Two running Modes
Command Line Mode
(1) use notepad ++ to write hello. py, for example, print 'Hello world'
(2) Open the command line window in the saved path
Distinguish PythonInteraction Mode:
C: \> is the command line mode provided by Windows, and >>> is in the Python interactive environment.
In command line mode, you can run python to enter the Python interactive environment, or you can run python hello. py to run a. py file. However, in the Python interactive environment, you can only enter Python code for execution.
Summary
Use a text editor to write a Python program and save it as a file suffixed with. py. Then you can run the program directly in Python.
What is the difference between the Python interaction mode and directly running the. py file?
Directly input python to enter the interaction mode, which is equivalent to starting the Python interpreter, but wait for you to input the source code one line at a time and execute one line at each input line.
Directly running the. py file is equivalent to starting the Python interpreter and executing the source code of the. py file at one time. You have no chance to enter the source code.
Using Python to develop programs, you can write code in a text editor while opening an interactive command window. During code writing, part of the code is stuck to the command line for verification!