在任何函数都有返回值,一般都是想到return 关键词,在函数生成器中有个关键词 yield 也可以做返回值,在函数没调用之前,是不会输出任何东西的

 1,return 用法

      def stu():

    return 'hello'

      stu()

 2,yield用法

     def stu():

              a,b=1,1

              b=a+1             

    yield b

    return 'hello'

      stu()

文章来自 http://www.96net.com.cn/

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-01
  • 2021-12-21
  • 2021-09-21
  • 2022-12-23
  • 2022-12-23
  • 2021-12-18
猜你喜欢
  • 2021-05-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案