Use of try...finally

Source: Internet
Author: User

Use of try...finally

If you want to implement whether an exception occurs in the middle, output a string of strings

Try

#print I

Finally

Print "Regardless of whether the above is abnormal, I must output!" "


The second example: to implement a string of strings output 10 million times, if the exception occurs, you need to determine how many times the previous output.

Try

For I in Range (10000000):

Print "I'm going to output 10 million times, I'm in the middle of the output, and I don't know how many times it is now."

Finally

Print "The value of I at this time is:" +str (i) + "--not complete output"


This article from "My Space" blog, reproduced please contact the author!

Use of try...finally

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.