简体   繁体   中英

Python - blocks: try, except

If there are more than one except: branches after the try: , can we say that:

  • one or more of the try: blocks will be executed
  • none of the try: blocks will be executed
  • not more than one try: block will be executed
  • exactly one of the try: blocks will be executed

In my opinion, the right answer will be "not more than one try: ", but maybe "one or more of the try: "?

It will show an error like this:

SyntaxError: default 'except:' must be last

You can either run this code:

try:
   something...
except:
   something...
finally:
   something...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM