首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > perl python >

python中急需留心的3

2012-09-14 
python中需要留心的3Arbitrary Argument ListsFinally, the least frequently used option is to specify

python中需要留心的3
Arbitrary Argument Lists

Finally, the least frequently used option is to specify that a function can be called with an arbitrary number of arguments. These arguments will be wrapped up in a tuple (see Tuples and Sequences). Before the variable number of arguments, zero or more normal arguments may occur.

>>> def parrot(voltage, state='a stiff', action='voom'):...     print "-- This parrot wouldn't", action,...     print "if you put", voltage, "volts through it.",...     print "E's", state, "!"...>>> d = {"voltage": "four million", "state": "bleedin' demised", "action": "VOOM"}>>> parrot(**d)-- This parrot wouldn't VOOM if you put four million volts through it. E's bleedin' demised !

热点排行