python基础一 day15 面试题

# def demo():
# for i in range(4):
# yield i
#
# g=demo()
#
# g1=(i for i in g)
# g2=(i for i in g1)
#
# print(list(g))
# print(list(g1))
# print(list(g2))

def add(n,i):
return n+i

def test():
for i in range(4):
yield i

g=test()
# for n in [1,10,5]:
# g=(add(n,i) for i in g)
n = 1
g=(add(n,i) for i in test())
n = 10
g=(add(n,i) for i in (add(n,i) for i in test()))
n = 5
g=(15,16,17,18)


print(list(g))
posted @ 2019-06-23 18:09  谭文章  阅读(168)  评论(0编辑  收藏  举报