Pythonマルチパラメータの付与(Tuple/List/Dict)


1、関数にTupleデータ型オブジェクトを渡す
#!/usr/bin/env pthon
#conding=utf8
def printYourEnter(input1,input2):
    """Document:just"""
    print input1
    print input2
    for var in input2:
        print var
if __name__ == '__main__':
    enter1 = raw_input("Pls enter your living city:")
    enter2 = raw_input("Pls enter your name:")
    enter3 = raw_input("Pls enter you age:")
    tuple1 = (enter2,enter3)
    printYourEnter(enter1,tuple1)

2、関数にListタイプオブジェクトを渡す
#!/usr/bin/env python
def printYourEnter(input1,x,y):
    print input1
    print x
    print y
if __name__ == '__main__':
    enter1 = raw_input("Pls enter your living city:")
    enter2 = raw_input("Pls enter name:")
    enter3 = raw_input("Pls enter your age:")
    li1 = [enter2,enter3]
    printYourEnter(enter1,*li1)

注意:
上の2つの例は2つの異なる表現形式であるが、実はこの2つの形式Tuple、Listはいずれも使用できる.
3、Dictionaryタイプオブジェクトを関数に渡す
#!/usr/bin/enb python
"""Documen:Just Dict value"""
def printYouEnter(input1,city,name,age):
    print input1
    print city
    print name
    print age
if __name__ == '__main__':
    enter1 = raw_input("Pls enter city:")
    enter2 = raw_input("Pls enter name:")
    enter3 = raw_input("Pls enter age:")
    dic = {'city':enter1,'name':enter2,'age':enter3}
    printYouEnter('a',**dic)