演示可变参数函数,可变参数函数,#演示可变参数函数#!/


#演示可变参数函数#!/usr/bin/pythondef f1(a,b): print a,bdef f2(a,*b): print a,bdef f3(a,**b): print a,bdef f4(a,*b,**c): print a,b,cdef f5(a,b=2,c=3): print a,b,cdef f6(a,b=2,*c): print a,b,cf1(1,2)    1 2f1(b=2,a=1)f2(1,2,3,4)       1 (2, 3, 4)f3(1,x=2,y=3,z=4)  1 {'y': 3, 'x': 2, 'z': 4}f4(1,x=2,y=3)    1 () {'y': 3, 'x': 2}f5(1)     1 2 3f5(1,4)    1 4 3f6(1)        1 2 ()f6(1,3,4,5,4)    1 3 (4,5,4)

评论关闭