1 def myFun(*argments): 2 values = [x for x in argments] 3 print(values) 4 myFun(1,2,3,4,5,6) 5 6 result: 7 [1, 2, 3, 4, 5, 6]
方法1
1 def myFunTwo(* argments): 2 values = list(argments) 3 print(values) 4 5 myFunTwo(1,2,3,4,5) 6 7 result: 8 9 [1, 2, 3, 4, 5]
方法2