Learn the basics of python interactive mode

Command line mode

Select "Command Prompt" in the Windows start menu to enter the command line mode. Its prompt is similar to C:\

Python interactive mode

Knock on the command python in the command line mode, and you will see a bunch of text output similar to the following, and then enter the Python interactive mode, its prompt is,

Enter exit() in the Python interactive mode and press Enter to exit the Python interactive mode and return to the command line mode:

**Distinguish between command line mode and Python interactive mode: **

In the command line mode, you can execute python to enter the Python interactive environment, or execute python hello.py to run a .py file

Executing a .py file can only be executed in command line mode. If you type a command python hello.py, you will see an error: The error message No such file or directory means that this hello.py cannot be found in the current directory. You must first switch the current directory to the directory where hello.py is located. carried out

There is a difference between running .py files in command line mode and running Python code directly in the Python interactive environment. The Python interactive environment will automatically print the results of each line of Python code, but it will not be possible to run the Python code directly.

In the Python interactive environment:

100+200+300600

In command line mode:

print(100+200+300)
C:\work pythoncalc.py
600

The code in the Python interactive mode is to input one line and execute one line, while running the .py file directly in the command line mode executes all the codes in the file at once. It can be seen that the Python interactive mode is mainly used for debugging Python code, and it is also convenient for beginners to learn. It is not an environment for officially running Python code!

summary:

In the Python interactive mode, you can directly enter the code, then execute it, and get the result immediately.

In the command line mode, you can run the .py file directly.

Knowledge point expansion:

Command line mode and python interactive mode

  1. In the command line mode, you can execute python to enter the Python interactive environment, or execute

Line python hello.py to run a .py file.

  1. In the Python interactive environment, you can only enter Python code and execute it immediately.

  2. The Python interactive environment will automatically print the results of each line of Python code, but it will not be possible to run the Python code directly.

The above is the detailed content of the basic knowledge points of the python interactive mode. For more information about the python interactive mode, please pay attention to other related articles on ZaLou.Cn!

Recommended Posts

Learn the basics of python interactive mode
Two days of learning the basics of Python
Basics of Python syntax
Consolidate the foundation of Python(7)
Consolidate the foundation of Python(6)
Consolidate the foundation of Python(5)
Consolidate the foundation of Python (3)
Learn the hard core operation of Python in one minute
The usage of wheel in python
Python handles the 4 wheels of Chinese
Python simulation of the landlord deal
What is the use of Python
How does python enter interactive mode
The premise of Python string pooling
Secrets of the new features of Python 3.8
The father of Python joins Microsoft
The operation of python access hdfs
The usage of tuples in python
End the method of running python
Python basics
Python basics 2
Python basics
Python basics 3
Python basics 4
Python basics 5
Understanding the meaning of rb in python
Can Python implement the structure of the stack?
What are the required parameters of python
Logistic regression at the bottom of python
The usage of Ajax in Python3 crawler
Python solves the Tower of Hanoi game
Solve the conflict of multiple versions of python
What is the scope of python variables
Python implements the sum of fractional sequences
What is the id function of python
Where is the pip path of python3
The essence of Python language: Itertools library
What are the advantages of python language
The specific method of python instantiation object
python3 realizes the function of mask drawing
How to learn the Python time module
What is the prospect of python development
What is the function body of python
The specific method of python import library
Solve the conflict of multiple versions of python
What is the function of adb in python
Detailed explanation of the principle of Python super() method
The difference between the syntax of java and python
7 features of Python3.9
Python realizes the development of student management system
Python implements the shuffling of the cards in Doudizhu
The meaning and usage of lists in python
Solve the problem of python running startup error
Can the value of the python dictionary be modified?
Python implements the source code of the snake game
Detailed explanation of the usage of Python decimal module
How about learning python at the age of 27?
2.1 The Python Interpreter (python interpreter)
The consequences of uninstalling python in ubuntu, very
Python object-oriented basics
Python writes the game implementation of fishing master