Saltar al contenido

ejemplo de código de error de tiempo de ejecución de Python

Hola usuario de nuestra página, hallamos la solución a lo que buscabas, has scroll y la encontrarás un poco más abajo.

Ejemplo 1: lista de excepciones de Python

AssertionError			#Raised when assert statement fails.
AttributeError			#Raised when attribute assignment or reference fails.
EOFError				#Raised when the input() functions hits end-of-file condition.
FloatingPointError		#Raised when a floating point operation fails.
GeneratorExit			#Raise when a generator's close() method is called.
ImportError				#Raised when the imported module is not found.
IndexError				#Raised when index of a sequence is out of range.
KeyError				#Raised when a key is not found in a dictionary.
KeyboardInterrupt		#Raised when the user hits interrupt key (Ctrl+c or delete).
MemoryError				#Raised when an operation runs out of memory.
NameError				#Raised when a variable is not found in local or global scope.
NotImplementedError		#Raised by abstract methods.
OSError					#Raised when system operation causes system related error.
OverflowError			#Raised when result of an arithmetic operation is too large to be represented.
ReferenceError			#Raised when a weak reference proxy is used to access a garbage collected referent.
RuntimeError			#Raised when an error does not fall under any other category.
StopIteration			#Raised by next() function to indicate that there is no further item to be returned by iterator.
SyntaxError				#Raised by parser when syntax error is encountered.
IndentationError		#Raised when there is incorrect indentation.
TabError				#Raised when indentation consists of inconsistent tabs and spaces.
SystemError				#Raised when interpreter detects internal error.
SystemExit				#Raised by sys.exit() function.
TypeError				#Raised when a function or operation is applied to an object of incorrect type.
UnboundLocalError		#Raised when a reference is made to a local variable in a function or method, but no value has been bound to that variable.
UnicodeError			#Raised when a Unicode-related encoding or decoding error occurs.
UnicodeEncodeError		#Raised when a Unicode-related error occurs during encoding.
UnicodeDecodeError		#Raised when a Unicode-related error occurs during decoding.
UnicodeTranslateError	#Raised when a Unicode-related error occurs during translating.
ValueError				#Raised when a function gets argument of correct type but improper value.
ZeroDivisionError		#Raised when second operand of division or modulo operation is zero.

Ejemplo 2: tipos de excepción python

BaseException
   ] SystemExit
   ] KeyboardInterrupt
   ] GeneratorExit
   ] Exception
        ] StopIteration
        ] StopAsyncIteration
        ] ArithmeticError
        |] FloatingPointError
        |] OverflowError
        |] ZeroDivisionError
        ] AssertionError
        ] AttributeError
        ] BufferError
        ] EOFError
        ] ImportError
        |] ModuleNotFoundError
        ] LookupError
        |] IndexError
        |] KeyError
        ] MemoryError
        ] NameError
        |] UnboundLocalError
        ] OSError
        |] BlockingIOError
        |] ChildProcessError
        |] ConnectionError
        ||] BrokenPipeError
        ||] ConnectionAbortedError
        ||] ConnectionRefusedError
        ||] ConnectionResetError
        |] FileExistsError
        |] FileNotFoundError
        |] InterruptedError
        |] IsADirectoryError
        |] NotADirectoryError
        |] PermissionError
        |] ProcessLookupError
        |] TimeoutError
        ] ReferenceError
        ] RuntimeError
        |] NotImplementedError
        |] RecursionError
        ] SyntaxError
        |] IndentationError
        |] TabError
        ] SystemError
        ] TypeError
        ] ValueError
        |] UnicodeError
        |] UnicodeDecodeError
        |] UnicodeEncodeError
        |] UnicodeTranslateError
        ] Warning
             ] DeprecationWarning
             ] PendingDeprecationWarning
             ] RuntimeWarning
             ] SyntaxWarning
             ] UserWarning
             ] FutureWarning
             ] ImportWarning
             ] UnicodeWarning
             ] BytesWarning
             ] ResourceWarning

Ejemplo 3: error de tipo en python

try:...except SomeException:
    tb = sys.exc_info()[2]raise OtherException(...).with_traceback(tb)

Ejemplo 4: errores de tiempo de ejecución en Python

Misspelled or incorrectly capitalized variable and function names

-Attempts to perform operations (such as math operations) on data of the wrong type(ex. attempting to subtract two variables that hold string values)-Dividing by zero
-Attempts to use a type conversion function such asint on a value that can’t be converted to an int

Recuerda que puedes mostrar esta noticia si lograste el éxito.

¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)



Utiliza Nuestro Buscador

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *