python常见问题用三元组表示
-
SyntaxError: invalid syntax - This error occurs when there is a mistake in the syntax of the Python code. It could be a missing or extra character, or incorrect indentation.
-
NameError: name 'x' is not defined - This error occurs when a variable or function is used before it is defined or assigned a value.
-
TypeError: unsupported operand type(s) for +: 'int' and 'str' - This error occurs when trying to perform an operation on incompatible data types. For example, trying to add an integer and a string.
-
IndexError: list index out of range - This error occurs when trying to access an element in a list using an index that is outside the range of the list.
-
KeyError: 'key' - This error occurs when trying to access a dictionary using a key that does not exist in the dictionary.
-
AttributeError: 'str' object has no attribute 'append' - This error occurs when trying to use a method or attribute on an object that does not have that method or attribute.
-
ImportError: No module named 'module_name' - This error occurs when trying to import a module that does not exist or is not installed.
-
IndentationError: unexpected indent - This error occurs when there is an incorrect indentation in the code, such as mixing spaces and tabs or using the wrong number of spaces for indentation.
-
ValueError: invalid literal for int() with base 10 - This error occurs when trying to convert a string to an integer using the int() function, but the string does not represent a valid integer.
-
ZeroDivisionError: division by zero - This error occurs when trying to divide a number by zero, which is mathematically undefined
原文地址: https://www.cveoy.top/t/topic/hYzF 著作权归作者所有。请勿转载和采集!