def test(x, *args):
print(x)
print(args)
test(1,2,3,4)
C:\Users\user\AppData\Local\Programs\Python\Python36\python.exe “C:/Users/user/PycharmProjects/hellow python/test.py”
1
(2, 3, 4)
Process finished with exit code 0
def test(*args, ):
print(args)
test([2,3,4,9])
test(*[2,3,4,9])
C:\Users\user\AppData\Local\Programs\Python\Python36\python.exe “C:/Users/user/PycharmProjects/hellow python/test.py”
([2, 3, 4, 9],)
(2, 3, 4, 9)
Process finished with exit code 0
def test(x, *args,**params ):
print(x)
print(args)
print(params)
test(1, y = 6)
test(1, [3,4,5])
test(1, [3,4,5], y = 99)
C:\Users\user\AppData\Local\Programs\Python\Python36\python.exe “C:/Users/user/PycharmProjects/hellow python/test.py”
1
()
{‘y’: 6}
1
([3, 4, 5],)
{}
1
([3, 4, 5],)
{‘y’: 99}
Process finished with exit code 0
def test(x, *args,**params ):
print(x)
print(args)
print(params)
test(1, *[1,2,3],**{'name':'alex'})
C:\Users\user\AppData\Local\Programs\Python\Python36\python.exe “C:/Users/user/PycharmProjects/hellow python/test.py”
1
(1, 2, 3)
{‘name’: ‘alex’}
Process finished with exit code 0