Today we'll explore most of the exception errors in Python
The first exception is what, abnormal vernacular interpretation is not normal, the program is generally referred to the programmer input format is not standardized, or the requirements of the parameter type does not correspond, incomplete and so on.
For example, a lot of companies to send Apple notebooks at the end of the year, you think of the program thinking is (MAC) computer Notebook, the results give you an Apple + notebook ... The first type is wrong and the quantity is not correct.
Let's take a look at some of the common errors below:
nameerror name error Reason: Name ' A ' is not defined named a not yet defined simply means the program does not know a with a table who if a=1 that program will understand a for 1
So later encountered this kind of code only to find the wrong undefined A to assign it the corresponding value can be resolved.
All right, let's keep looking. The following is the next:
indexerror Index error (also called boundary error) Reason: The index of the list index out of range lists has exceeded its scope to cause
List A has only 2 parameters, subscript is 0,1 (do not understand the basis of the list), and I want to print the value of the subscript 2 position at this time more than its standard is not within the range
For example, take a bus 1.2-meter children under the free, the result of a 1.5-meter up can not be free because you exceed the specified height
Here we continue to continue:
keyerror Key value error generally occurs in the dictionary because there is no height in dictionary a key value, name has been printed because a inside already exists
The dictionary is made up of dict = {Key:value} One by one, which, for example, understands Dict is like a company that is identified by an employee key
Value equals the attribute of the employee (job, salary, personal information, etc.) this error is tantamount to a company to find someone, the results of the company said no such person.
Continue to continue:
importerror Import Error Reason: No module named nothing
Generally this error occurs in misspelled or case, no module method installed, no correct reference location (module update version may change method name or new folder)
At this time I recommend you go to python2.x or python3.x directory \lib\site-packages file inside look for See (third-party library module will be in these kinds of storage)
Continue to continue:
IOError input/Output error reason: No such file or directory: ' Test ' is not found in directory called Test
This is easy to understand. The program says, "Who are you digging?"
Continue to continue:
Attributeerror member property error reason: All objects However, there is no built-in function in the dictionary a object, that is, the built-in method is called sort, and everyone knows that the dictionary is unordered and the list has this method
When you define a variable that does not know what built-in functions and methods to use, you can use Dir to view the following methods that are currently available.
syntaxerror syntax error: Invalid syntax A is undefined so there's no way to convert it to integer this is one of the common mistakes
Let's look at the next:
TypeError type error: Unknown hash type list (later for personal understanding) but tuples can be put in a little confusing, the dictionary key is usually a cell or a unique identifier,
A sequence of immutable tuples is also a unique identity, so tuples can be placed in key. Metaphorically, as you are the only key in the world, is not exactly the same as you.
The above is often encountered the problem of the error, we have learned that you can think of solutions to their own so it is also conducive to the improvement of their own level.
Summary of exception errors appearing in Python basics