处理多个异常-python cookbook(第3版)高清中文完整版

时间:2024-06-29 23:06:52
【文件属性】:

文件名称:处理多个异常-python cookbook(第3版)高清中文完整版

文件大小:4.84MB

文件格式:PDF

更新时间:2024-06-29 23:06:52

python cookbook 第3版 高清 中文完整版

14.6 处理多个异常 问题 You have a piece of code that can throw any of several different exceptions, and you need to account for all of the potential exceptions that could be raised without creating duplicate code or long, meandering code passages. 解决方案 If you can handle different exceptions all using a single block of code, they can be grouped together in a tuple like this: try: client_obj.get_url(url) except (URLError, ValueError, SocketTimeout): client_obj.remove_url(url)


网友评论