This article mainly introduces the usage of Python variable parameter functions. The example analyzes the definition and usage skills of Python variable parameter functions, which has some reference value, for more information about how to use Python variable-parameter functions, see the example in this article. Share it with you for your reference. The details are as follows:
#! /Usr/bin/pythondef f1 (a, B): print a, bdef f2 (a, * B): print a, bdef f3 (a, ** B ): print a, bdef f4 (a, * B, ** c): print a, B, cdef f5 (a, B = 2, c = 3): print a, B, cdef f6 (a, B = 2, * c): print a, B, cf1 (1, 2) f1 (B = 2, a = 1) f2 (1, 2, 3, 4) f3 (1, x = 2, y = 3, z = 4) f4 (1, x = 2, y = 3) f5 (1) f5 (1) f6 (1) f6 (1, 3, 4, 5, 4)
#! /Usr/bin/pythondef echoo (* args, ** kwargs): print args, kwargsechoo (1, 2, a = 3, B = 4) pargs = (1, 2) pkwargs = {'a': 3, 'B': 4} apply (echoo, pargs, pkwargs)
I hope this article will help you with Python programming.