新手初学python,输出的结果跟我想象中不一样
 `#定义一个类的装饰器Bold
class Bold(object):
    def __init__(self, func):
        self.func = func
    def __call__(self, *args, **kwargs):
        return '<b>' + self.func(*args, **kwargs) + '</b>'
        
   
    #相当于 hello=Bold(hello) 生成一个hello.func为hello函数的
    #Bold实例化对象  
    @Bold                        
    def hello(name):
        return 'hello %s' % name`
        
    #然后我打算传多个参数 *args
    >>> hello('ss','sss','aa')
    File "<stdin>", line 5, in __call__
    TypeError: hello() takes exactly 1 argument (3 given)`
    
    
这里完全不理解,这里的hello()里的参数不是__call__的args, *kwargs 吗,为什么变成只能是一个参数?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
*args,**kwargs分别是表示可以接收可变参数和关键字参数,可以接收任何0个或者1个或者多个参数。*args,**kwargs组合起来就是说__call__能接收任何参数啦~~但是顺序要对。