Python—— *与** 参数说明
生活随笔
收集整理的這篇文章主要介紹了
Python—— *与** 参数说明
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Python *與** 參數說明
'''*用來傳遞任意個無名字參數,這些參數會一個Tuple的形式訪問''' def fall(*z):print sum(z)print "keys type=%s" % type(z)print "keys=%s" % str(z)for i in range(0, len(z)):print "keys[" + str(i) + "]=%s" % str(z[i]) fall(1,2,3,4)輸出結果:
10
keys type=<type 'tuple'>
keys=(1, 2, 3, 4)
keys[0]=1
keys[1]=2
keys[2]=3
keys[3]=4
輸出結果:
{'a': 1, 'b': 2, 'name': 3, 'd': 5}
keys type=<type 'dict'>
keys={'a': 1, 'b': 2, 'name': 3, 'd': 5}
name=3
?
轉載于:https://www.cnblogs.com/lixin890808/p/5133634.html
總結
以上是生活随笔為你收集整理的Python—— *与** 参数说明的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: zz bond配置网络: 两个网卡一个i
- 下一篇: TabControl控件用法图解