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
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