Python-shell Feedback Common Errors
Beginners often use Python-shell to learn the basics of Python and grammar, and when using Python-shell , they will encounter errors such as mistakes, grammatical errors, or misspelled functions or variable names. , now a summary of the mistakes that beginners often make.
variables, functions not defined
Let's briefly summarize the common error hints when using Python-shell.
>>>len = 12>>>letraceback (most recent): File ' <pyshell#36> ', line 1, in <module> Lenameerror:name ' Le ' is not defined>>>
The top Python-shell feedback nameerror:name ' Le 'is not defined, which is said ' le ' variable undefined, indeed, because before we were assigned the Len variable equals 12, Le no assignment is not created so the error is not defined.
>>>len = "www.jeapedu.com" >>> Pint (len) Traceback (most recent call last): File "<pyshell#38>", L Ine 1, in <module> Pint (len) nameerror:name ' pint ' are not defined>>>
From the top Idle-shell feedback nameerror:name ' pint 'is not defined, you can see that the pint function is undefined, it should be the function of print less R letter.
Non-statement characters
In the Python statement instructions put some non-statement characters, how to understand? For example, hitting a (multiple) space before the print function or pressing the TAB key will cause an error when running the statement in Python-shell.
>>> s = ' www.jeapedu.com ' >>> print swww.jeapedu.com>>> print s File "<pyshell#45> ; ", line 1 print s ^indentationerror:unexpected indent>>>
The reason for the 4th line error is that there is a tab or several spaces in front of the print function that causes the syntax to be out of compliance in the Shell and report an error.
This article is from the "Python Training Zhipu Education" blog, so be sure to keep this source http://jeapedu.blog.51cto.com/7878264/1617006
Basic Python Basics Tutorial Python tools common errors