Python 函数,,#-*- codin
Python 函数,,#-*- codin
#-*- coding:utf-8 -*-‘‘‘def 函数名(参数列表):[tab键] command[tab键] command...‘‘‘def showHello(): print("hello world .")#定义带参数的函数def add(num1,num2): print("%d+%d=%d"%(num1,num2,num1+num2))#定义带返回值的函数def mult(num1,num2): return num1*num2#函数中多个值的返回def return_more(): a = 11 b = 22 c = 33 #return [a,b,c] #做一个列表返回 #return (a,b,c) #做一个元组返回 return a,b,c #这也是做一个元组返回#函数的调用showHello()add(2,3)print(mult(3,5))nums = return_more()for tmp in nums: print(tmp)
同一文件中,python的函数名不能使用相同的函数名
Python 函数
评论关闭