摘要: 在python中,反射包含以下几个函数 def hasattr(*args, **kwargs): # real signature unknown """ Return whether the object has an attribute with the given name. This is 阅读全文
posted @ 2018-11-15 16:17 hukey 阅读(378) 评论(0) 推荐(0)
摘要: 类中的私有属性 在类中定义一个私有属性如下: 私有属性的使用场景: 虽然私有属性不能直接从外部调用,但是我们可以通过对象.__dict__ 尝试来获取这个属性试试: 使用对象通过 _类名__属性名 来获取属性的方式并不推荐,在python中没有强制不允许查看类中私有属性,一切都靠自觉; 将类中的方法 阅读全文
posted @ 2018-11-15 14:52 hukey 阅读(397) 评论(0) 推荐(0)