Python函式基礎(day3)

weixin_33766168發表於2017-11-09
112323121def 函式名(引數1,引數2,引數3,...)'''註釋'''return234123'''定義階段'''def tell_tag(tag,n)#有引數def tell_msg()#無引數'hello world''''呼叫階段''''*'12'*'12'''執行結果'''1122returnreturn11return'''什麼時候該有返回值?''''''什麼時候不需要有返回值?'''3123'hello'3'hello'12121231234def foo(x,y,*args)12345def foo(x,y,*args)12345def foo(x,y,z)123def foo(x,y,**kwargs)12123def foo(x,y,**kwargs)12'a':1'b':2'c':3def foo(x,y,z)'z':1'x':2'y':3def foo(x,y)def wrapper(*args,**kwargs)'====>'5def foo(x,y,*args,a=1,b,**kwargs)1234534523453'c'4'd'51PS:def auth(name,age,sex)def auth(name,age,sex='male')'male'def auth(name,age,sex)'female'2def auth(name,age,sex)'test'18'male''test''male'18def number(x,y,*args)123456123456def auth(name,age,sex='male',**kwargs)'test'18'male''shanxi',如需轉載請自行聯絡原作者

相關文章