不固定参数个数的传参与取值
1、PHP
function demo() {
print_r(func_get_args());
}
function demo2(...$args) {
print_r($args);
}
2、python
def demo(*args):
print(*args)
print(args)
demo()
# output:
#1:
#2: ()
demo('a', 3)
# output:
#1: a 3
#2: ('a', 3)
var code = “6313904e-8b9d-47f6-aecb-93b3a330ac7d”

本文比较了PHP和Python中处理可变数量参数的方法,通过`func_get_args`和Python的星号解包`*args`展示了函数接受并打印参数的不同方式。
765

被折叠的 条评论
为什么被折叠?



