#函数后面如果没有return系统会默认return none
def ff():
print("打印return")
return 15 # 函数在执行中遇到return就会停止执行,并返回结果,所以后面的不会被执行
print("不会被执行")
a = ff()
print(a) #return的值会返回给函数ff()
def jiafa(*args):
num = 0
for i in args:
num += i
print(num)
return num #return 结束,并把返回值num返回给jiafa(1,2,3,4,5)
b = jiafa(1,2,3,4,5)
print(b)
def fanhui():
return 1,2,"abc",["a","b"]
c = fanhui()
print(c) #return中出现多个对象,解释器会把他们组装成一个元组输出
#(1, 2, 'abc', ['a', 'b'])