def test(x, *args): print(x) print(args) print(args[0]) test(1, 2, 3, 4, 5) --------------------->> 1 (2, 3, 4, 5) 2
*args 可接收n(n>=0)个值
def test(x, **kwargs): print(x) print(kwargs) test(1, y=1, z=2) ----------------->> 1 {‘y‘: 1, ‘z‘: 2}
**kwargs 可接收 关键词参数 输出为字典的形式
时间: 2024-12-29 23:11:21