函数常用类型
    无参数,无返回值
    无参数,有返回值
    有参数,无返回值
    有参数,有返回值
2.无参数,无返回值
    无参数无返回值  
        def hello():  
            print("hello world")  
        hello()  
    # 有参数无返回值  
        def add(x, y):  
            print(x + y)  
        add(10, 20)
    # 无参数有返回值  
        def sleep():  
            return "sleep"   
        s = sleep()  
        print(s)  
    # print(sleep()) 等价于上面两句  
        def sub(x, y):  
            return x * y  
        res = sub(12, 6)  
        print(res) 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-31
  • 2021-08-14
  • 2022-01-23
猜你喜欢
  • 2022-12-23
  • 2021-09-07
  • 2021-12-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案