python error feedback

Any compiler interpreter will help programmers quickly locate the compilation error to help programmers quickly modify coding errors, as does Python interpreter:
when there are errors in the program, the Python interpreter will do its best to help you find The problem is that when the program fails to run successfully, the interpreter will provide a traceback. Traceback is a record that points out where the interpreter is stuck when trying to run code. For example, carelessly spelling the variable name wrong (writing Huahua into peony, haha, peony is of course reluctant ~~)

test-1.py
1 message = "Hello Python Crash Course reader!"
2 print(mesage)

operation result:

[email protected]:~/python$ python test-1.py 
Traceback (most recent call last):
File "test-1.py", line 2, in <module>
print(mesage)
NameError: name 'mesage' is not defined

It is suggested that the message in the second line of line 2 is not defined. Well, let's follow its treasure hunt directions and go to the file to find it. After modification:

 test-1.py
 1 message = "Hello Python Crash Course reader!"
 2 print(message)

Look at the results. Run it:

[email protected]:~/python$ python test-1.py 
Hello Python Crash Course reader!

Well, the results are fruitful, and you're done. It's still quite easy. Congratulations. You have mastered a good skill line.

Published 53 original articles · praised 16 · visits 2213

Guess you like

Origin blog.csdn.net/m0_37757533/article/details/104855797