Home > Backend Development > Python Tutorial > What are params in python

What are params in python

silencement
Release: 2020-09-16 09:20:13
Original
45029 people have browsed it

Through the previous study, we have learned how to customize functions in Python. Today we will talk about params in Python function parameters

What are params in python

If we already know the number of function parameters, we can just pass it to the function directly, but in most cases , we don’t know the number of function parameters, how to solve this? This uses the params parameters in Python!

PythonThe parameter collection mechanism uses the asterisk "*" to implement . Here, a "*" is added in front of the specified parameter params. "*" means to use params parameters to collect An indefinite number of parameters are passed in, and the collected parameters are stored in params in the form of tuples. If no parameters are passed in, params is an empty tuple

For example

What are params in python

What are params in python

As you can see from the above, no matter how many parameters are passed to the function, it will work well through the params parameter collection mechanism. solution!

Related learning recommendations: python tutorial

The above is the detailed content of What are params in python. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template