Python函数

1.

定义一个函数

def func1():
    """testing1"""
    print("hello world1")
    return 0

定义一个过程,过程是没有返回值的函数,Python中过程隐式返回None

def func2():
    """testing2"""
    print("hello world2")

所以调用函数func1,func2的时候无论有没有return值,都可以把函数赋给一个值,比如

x = func1()

#输出
hello world1

y = func2()

#输出
hello world2

print(x)

#输出
0

print(y)

#输出
None

 

posted @ 2020-11-22 20:10  少年_不识愁滋味  阅读(80)  评论(0编辑  收藏  举报