#_author:来童星
#date:2019/12/12
from greenlet import greenlet
def test1():
print(12)
gr2.switch()
print(34)
gr2.switch()
def test2():
print(56)
gr1.switch()
print(78)
gr1 = greenlet(test1)# <greenlet.greenlet object at 0x00000293A37F4048>
gr2 = greenlet(test2)
gr1.switch()
运行结果:
12
56
34
78
56
78