执行一下代码的结果是? class A: def __init__(self,a,b,c): self.x = a+b+c a = A(1,2,3) b = getattr(a,'x') setattr(a,'x',b+1) a.x A 0 B 6 C 7 D 8 答案是 C getattr内置函数,得到对象属性,由英文就可以看出来,getattr -> get attribute setattr内置函数,设置对象属性,由三个参数(objecet,attr,default)…
php中实现事件模式 https://yq.aliyun.com/ziliao/162660 <?php class Event{ private $events = []; public function listen($name, $callback){ if(!key_exists($name, $this->events)) $this->events[$name] = $callback; } public function trigger($name){ if(key_exi…