所以我的问题专门针对下面示例顶部的装饰器。我不明白小写装饰器函数的第 3 行。我很困惑为什么它会返回一个列表,如果它在那些方括号中,这意味着它是一个列表,对吗?另外,我不完全理解'func(*args)'那一行的结尾,这是否只是意味着'func'的任意参数(在这种情况下是displayPeople)?
def lowercasedecorator(func):
def wrapper(*args):
return [i.lower() for i in func(*args)]
return wrapper
class People():
totalpeople = 0
def __init__(self, name, age, phone):
self.name=name
self.age=age
self.phone=phone
People.totalpeople += 1
@lowercasedecorator
def displayPeople(self):
return self.name, self.age, self.phone
ben = People("bEn", "20", "5034950293")
print ben.displayPeople()