This article is an example of Python eliciting tuples from function parameter types. Shared for your reference, as follows:
Custom Functions: Special Arguments
def show(name="jack", *info): print(name) #jack print(info) #(22, 'male') show("jack",22,"Male.")
it can be seen22, "Male"
All grouped into the second argument of the function*info
。
We can see that printing thisinfo
Parameters result in: parenthesis-wrapped form.
Special parameter upgrades for functions
See above for function arguments*xxx
In this form, take a look below at 2*
The form of the
def show(name="jack", **info): print(name) #jack print(info) #{'sex': 'male', 'age': 22} show("jack",age=22,sex="Male.")
**info
Note that at this point it's 2*
The function prints a string that looks like a json structure. The function prints internally to get a string that looks like a json structure.
What the heck are the three parameters? What's the difference?
Let's look at this with Pytone's built-in function type
def show(name="jack",*info1, **info2): print(type(name)) print(type(info1)) print(type(info2)) show("jack",22,"Male.",age=22,sex="Male.")
Guess: what would be the type of parameter to print these 3?
<class 'str'>
<class 'tuple'>
<class 'dict'>
name
is a string.*info1
is a tuple.**info2
It's the dictionary.
Tuple
(22, 'Male')
element in the form of a parenthesis wrapped around it.
For more Python related content, readers can check out this site's topic:Python list (list) manipulation techniques summarized》、《Summary of Python coding manipulation techniques》、《Python Data Structures and Algorithms Tutorial》、《Summary of Python function usage tips》、《Summary of Python string manipulation techniques》、《Python introductory and advanced classic tutorialsand theSummary of Python file and directory manipulation techniques》
I hope that what I have said in this article will help you in Python programming.