python函数学习--函数的四种返回值形式

python中函数返回常用一下四种类型,
def test1():
    print("in the test1")#无返回值

def test2():
    print("in the test2")#返回0
    return 0

def test3():
    print("in the test3")#返回参数
    return 'test3'

def test4():
    print("in the test4")#返回函数
    return test2()
x=test1()
y=test2()
z=test3()
a=test4()
print(x)
print(y)
print(z)
print(a)

对应执行结果如下:
in the test1
in the test2
in the test3
in the test4
in the test2
None
0
test3
0

你可能感兴趣的:(python)