JZTXT
  • 首页
  • Ai
  • Java
  • Python
  • Android
  • Mysql
  • JavaScript
  • Html
  • CSS

异常处理以及for循环底层练习

发布时间 2023-08-08 22:26:35作者: ranbo145

异常处理

try:
    "被监测的代码(可能会出错的代码)"
except: 错误类型 as e:
	"针对上述错误类型制定的方案"
     print(e)
# 万能异常
except Exception as e:
    print(e)

小练习

# 练习题 利用while循环,迭代器对象和异常监测来完成for的功能
l1=[11,22,33,44,55,66,77,88,99]
res = l1.__iter__()
while True:
    try:
        ret=res.__next__()
        print(ret)
    except Exception as e:
        break

 

    本栏目推荐文章
  • 微信小程序 取列表的for循环的第一个值
  • SHARPNESS-AWARE MINIMIZATION FOR EFFICIENTLY IMPROVING GENERALIZATION论文阅读笔记
  • 8- for循环与range()
  • 7 - for循环while循环 1+2+...+100和
  • 如何让Visual Studio Tools for Unity插件用于调试你自己的Mono嵌入应用程序
  • 6- for循环
  • 《RAPL: A Relation-Aware Prototype Learning Approach for Few-Shot Document-Level Relation Extraction》阅读笔记
  • An improved LSTM-based model for identifying high working intensity load segments of the tractor load spectrum
  • web项目启动时dubbo报错: No provider available for the service com.davidhu.shopguide.api.service.UserEventService from the url zookeeper ://localhost:2181/org.apache.du
  • day4: BigDecimal类, Arrays类, 包装类, String类 , Collection+迭代器,增强for
版权声明:本网站为非赢利性站点,本网站所有内容均来源于互联网相关站点自动搜索采集信息,相关链接已经注明来源。
联系我们