好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

python如何使用send唤醒

说明

1、除了可以使用next()函数唤醒生成器继续执行外,还可以使用send()函数唤醒执行。

2、使用send()函数的优点之一是可以在唤醒的同时将附加数据传输到断点。

实例

def fun():
    i = 0
    while i<5:
        temp = yield i
        print(temp)
        i+=1

以上就是python使用send唤醒的方法,希望对大家有所帮助。 更多编程基础知识学习: python学习网

本文教程操作环境:windows7系统、Python 3.9.1,DELL G3电脑。

查看更多关于python如何使用send唤醒的详细内容...

  阅读:24次