Python exception record and Python record

Source: Internet
Author: User

Python exception record and Python record

1. Common Exception name

 

AttributeError indicates an exception caused by calling a method that does not exist.

EOFError encountered an exception at the end of the file.

Exception caused by an error in the ImportError import module.

An exception occurs when the IndexError list is out of bounds.

IOError I/O operations, such as file opening errors.

KeyError indicates an exception caused by a keyword that does not exist in the dictionary.

NameError indicates an exception caused by a nonexistent variable name.

An exception caused by incorrect TabError block indentation.

Exception caused by a value that does not exist in the ValueError search list.

An exception caused by zero ZeroDivisionError.

 

2. Syntax

Try:

... Guarded clause...

Struct t... expression ...:

... Exception handler codee...

Finally:

... Clean-up code...

 

3. raise statement

Def crossProduct (seq1, seq2 ):

If not seq1 and not seq2:

Raise ValueError, "Sequence arguments must be non-empty ."

Return [(x, y) for x1 in seq1 for x2 in seq2]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.