发布时间:2019-09-10 08:55:29编辑:auto阅读(2350)
Python允许你实时地创建函数参数列表. 只要把所有的参数放入一个元组中, 然后通过内建的 apply 函数调用函数. 如 Example
1-1.
File: builtin-apply-example-1.py
def function(a, b):
print a, b
apply(function, ("whither", "canada?"))
apply(function, (1, 2 + 3))
apply
Removes usage of apply(). For example apply(function, *args, **kwargs) is converted to function(*args, **kwargs).
意思说, 取消了appy方法的使用,例如,用function(* args, **kwargs) 代替了方法appy
所以上文例子如下面写:
>>> def add(a, b):
print(a,b)
>>> add('I am', ' albertshao')
I am albertshao
上一篇: Python这五个就业方向最有前途和发展
下一篇: Python 模拟Ajax/XMLHtt
51743
51418
41833
38602
33100
30093
28762
23761
23673
22041
66°
2268°
2961°
2467°
2412°
3007°
2421°
3224°
5313°
5137°