函数返回值1

#函数的返回值

def test1():

print "one" #无return 返回none

def test2():

print "two"

    return 0  #返回0

def test3():

print ('three')

return 1,'hello',['alex','wupeiqi'],{'name':"alex"}#返回值多个值,返回的是元祖

x=test1()

y=test2()

w=test3()

print (x)

print (y)

print (w)

打印结果:

one

two

three

None

0

(1, 'hello', ['alex', 'wupeiqi'], {'name': 'alex'})


1、无返回值时,返回的是none 

2、返回为0 时,返回0

3、返回多个值时,返回的是一个元祖

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容