The wrong kinds of Python programs
There are two kinds of errors in Python programs. One is syntax errors (syntax error). This error is that the writing of the statement does not conform to the grammatical rules of the Python language. The second is a logical error (logic error). This error refers to the program can run, but the function does not meet expectations, such as "wrong" situation.
error not defined by variable
In a python program, variables need to be defined before they are used. If this is not done, the variable does not have a defined error. This is a grammatical error. In Pycharm, syntax errors are marked with red wavy lines, as shown in Figure 1.
Figure 1 Pycharm, syntax errors are marked with red wavy lines
error message run by Python program
In Pycharm, the program runs an error, and the error message is reported in the Run window (that is, the input data or the Output window). By forcing the example of Figure 1, the error message shown in Figure 2 will be rendered.
The error message is reported in the Run window below Figure 2
Error message, the display lists the program's running trajectory (traceback). Here, the running trajectory is not long, you will encounter a very long situation. There is only one running trajectory that indicates the 3rd line (lines 3) in the file 2-2-5-varerror.py, the content is "print (mesage) #mesage的拼写错了, missing an S", there is an error. The file path is a blue font program that indicates that it is a hyperlink, and clicking on it lists the line code and the code nearby.
At the end of the error message, the wrong conclusion is given, Nameerror:name ' mesage ' is not defined. The name is wrong: The variable name ' mesage ' is undefined.
Learn to analyze error messages for Python programs. Although it is in English, you will catch the essentials if you read more. Using error messages, you can quickly locate errors and correct errors.