Detailed explanation of the difference between Python interactive mode and direct running. py file

  • 2021-07-06 11:20:06
  • OfStack

See something like C:\ > Is in the command line mode provided by Windows, see > > > Is in the Python interactive environment.

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

Type environment, only Python code can be entered for execution.

What is the difference between the interactive mode of Python and running the. py file directly?

Directly entering python into interactive mode is equivalent to starting the Python interpreter, but waiting for you to enter the source code line by line, every input line will execute one line.

Running the. py file directly is equivalent to starting the Python interpreter, and then executing the source code of the. py file once. You have no chance to input the source code.

Using Python development program, you can write code in the text editor and open an interactive command window. In the process of writing code, part of the code is glued

Go to the command line to verify and get twice the result with half the effort! The premise is to have a 27 'super-large monitor!


Related articles: