try- except代码块
时间: 2023-10-04 21:12:48 浏览: 80
try-except代码块是一种异常处理机制,在程序中用来捕捉和处理可能引发的异常。try块包含可能引发异常的代码,而except块用来处理异常。当程序执行到try块时,如果没有发生异常,会跳过except块继续执行后续代码;如果try块中发生了异常,会跳到相应的except块中处理异常,并在异常处理完后继续执行后续代码。try-except代码块的基本语法格式是try块后跟一个或多个except块,每个except块可以处理一个或多个特定类型的异常。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *3* [Python try except异常处理详解(入门必读)](https://blog.csdn.net/Itmastergo/article/details/129313791)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* [20201209_117_try_except基本结构](https://blog.csdn.net/MinskyYi/article/details/111003838)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文