标签:for循环 异常 top pre ext 解析 运算 class iad
l = {1,2,3}
iter_l = l.__iter__() #将列表转换为迭代器
print(iter_l.__next__())
print(next(iter_l))
def f():
for i in range(10):
yield i
t = f()
print(t.__next__())
print(t.__next__())
print(t.__next__())
xiadangongji = ("鸡蛋%s" %i for i in range(10))
print(xiadangongji.__next__()) #鸡蛋0
print(xiadangongji.__next__()) #鸡蛋1
age = 18
res = "未成年" if age < 18 else "已成年"
print(res)
egg = ["鸡蛋%s" %i for i in range(10)]
print(egg) #['鸡蛋0', '鸡蛋1', '鸡蛋2', '鸡蛋3', '鸡蛋4', '鸡蛋5', '鸡蛋6', '鸡蛋7', '鸡蛋8', '鸡蛋9']
egg2 = ["鸡蛋%s" %i for i in range(10) if i > 5]
print(egg2) #['鸡蛋6', '鸡蛋7', '鸡蛋8', '鸡蛋9']
标签:for循环 异常 top pre ext 解析 运算 class iad
原文地址:https://www.cnblogs.com/L-dongf/p/10657649.html