python yield

def test():
    print('enter')
    yield  1
    print('next')
    yield  2
    print('next next')
    yield  3


for i in  test():
    print(i)

 output

enter
1
next
2
next next
3

 This shows the role of yield, and you will know it when you debug it.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326182004&siteId=291194637