函数的定义def
def 函数名(参数):
pass(函数体)
return
注,如果函数没有return,则返回none.同时也要注意顺序,要先定义再引用。return后的所有语句都不会被执行。当返回多个值时,直接用逗号隔开。如return x,y,z
函数返回多值实例
def tngh(x,y):
a=x*9+6
b=y+61-8
return a,b
restngh=tngh(6,9) 此句也可写为res1_tngh,res2_tngh=tngh(6,9) 此处restngh,res1_tngh,res2_tngh为任一变量名
print(restngh[0],restngh[1]) 同上 print(res1_tngh,res2_tngh)
原文:https://www.cnblogs.com/tngh/p/9313334.html