try,except用法

1 lst = ["皇阿玛", "皇额娘", "容嬷嬷", "紫薇"]
2 # 模拟for循环
3 it = lst.__iter__()
4 while True:
5     try:
6         name = it.__next__()
7         print(name)
8     except StopIteration: # 拿完了
9         break

 

posted @ 2018-07-18 00:04  Niuli'blog  阅读(695)  评论(0编辑  收藏  举报