码迷,mamicode.com
首页 > 编程语言 > 详细

python 那些‘魔法函数’

时间:2018-05-03 10:22:26      阅读:182      评论:0      收藏:0      [点我收藏+]

标签:value   sel   ini   name   pre   rgs   int   ems   init   

#__setattr__ __delattr__
class
Test: def __init__(self, **kwargs): for k, v in kwargs.items(): setattr(self, k, v) def __delattr__(self, item): print(item) def __setattr__(self, key, value): print(key, value) t = Test(name=zhangsan, heigth=180)

 

python 那些‘魔法函数’

标签:value   sel   ini   name   pre   rgs   int   ems   init   

原文地址:https://www.cnblogs.com/alplf123/p/8983888.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!