编程语言
首页 > 编程语言> > python传递任意数量的实参

python传递任意数量的实参

作者:互联网

#!/usr/bin/python
#coding=utf-8
#好好学习,天天向上
def make_pizza(*toppings):
    print("\nmaking a pizza with the following toppings:")
    for topping in toppings:
        print(f"-{topping}")
make_pizza('grafana')
make_pizza('tiger','jenkins','database','linux','windows')
#*toppings为形参。让python创建一个名为toppings的空元组,并将接受到的多个实参全部封装到这个元组当中

  

 

标签:python,make,toppings,print,实参,任意,pizza
来源: https://www.cnblogs.com/tigergaonotes/p/14256525.html