python 元組和字典中元素作為函數調用參數傳遞


模式1. 

def test1(*args):

    test3(*args)

def test2(**kargs):

    test3(**kargs)

def test3(a, b):

    print(a,b)

test1(1,2)
test2(a=1,b=2)

模式2. 

def test4(a= ()):

    test6(*a)

def test5(b = {}):

    test6(**b)

def test6(a, b):

    print(a,b)

test4((1, 2))
test5({'a':1,'b':2})

關於構建Python不定參數函數請移駕至:http://www.cnblogs.com/doudongchun/p/3704108.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM