Function call with the *operator to unpack the arguments out a list or tuple. When the arguments are in the form of a dictionary, we can unpack them during the function call using the ** operator. A double asterisk ** is used for unpacking a dictionary and passing it as keyword arguments during the function call.
Code:
def _test_a(*args,**kvargs):
if args:
_test_function(*args)
elif kvargs:
_test_function(**kvargs)
def _test_function(stringValue,intValue,floatValue):
print('value1:%s, value2:%d, value3:%f' % (stringValue,intValue,floatValue))
_test_a('Mike',7,5.2)
list_params=['Harry',6,9.2]
_test_a(*list_params)
dict_params={'stringValue':'Tom','intValue':9, 'floatValue':7.2}
_test_a(**dict_params)
Auf dieser Seite können Sie das Online-Video 20. Function Argument Unpacking in Python || * and ** Statements Python Programming Tutorial mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Bhavatavi 27 Juni 2022 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 3 Mal angesehen und es wurde von 0 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!