What is the use of the python interactive interface, how to open the python interactive interface

Hello everyone, let me share with you what is the use of the python interface. Many people don't know this yet. Explain in detail below. Let's see now!

 

What is an interactive python interpreter

An example to illustrate the interactive explanation (see Onion - Lao Yang's explanation below)

Example: Create the file zoo.py. In this file, the function hours() is defined to output the string 'Open 9-5 daily' ai pseudo-original api, how to call it with php .

Then use the interactive interpreter to import the module zoo and call the function hours().

Preparation steps: We can first use any editor to edit a zoo.py file def hours():

print('Open 9-5 daily')

Step 1: Open the IDLE that comes with installing Python (the default >>> is under the CPython interpreter, but it is not interactive)

Step 2:

Step Annotate this step) This step is just to explain, you don't need to do this step

Step 3) Run this zoo.py to start interacting

Step 4) When you see the >>> prompt, it becomes the interpreter state again

Step 5), at this time we can import that module (actually it is the file name without extension zoo ###Be careful not to add extension)

What is python interactive mode

As shown in the figure, after editing a line of code, it will be executed immediately after pressing Enter to get the result, which is the interactive mode.

How to make an interactive interface with python

The questioner said the opening method under the dos command: the method is the full path name of the Python file: of course, you can also right-click, select Edit With IDLE, and then directly press F5 to run; or double-click.

Copyright statement: All articles on this site are original, welcome to reprint or forward, please keep the website address and author information.

Guess you like

Origin blog.csdn.net/mynote/article/details/132448453