class Person:
def __init__(self,name):
self.name=name
def sayhello(self):
print('My name is:',self.name)
def allFruits(self,*a,**b):
print(a,b)
p=Person('Bill')
p.sayhello()
p1=Person('zyy')
p1.allFruits('香蕉','橘子','火龙果',kk="456",gg=123)
#"*"表示,函数可以接受多个参数,全部放入一个元祖中。
#"**"表示,函数可以接受多个参数,全部放入一个字典中。
输出:
My name is: Bill
(‘香蕉’, ‘橘子’, ‘火龙果’) {‘kk’: ‘456’, ‘gg’: 123}