快上网专注成都网站设计 成都网站制作 成都网站建设
成都网站建设公司服务热线:028-86922220

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

python通过点操作符和reduce遍历对象的属性的代码

如下的资料是关于python通过点操作符和reduce遍历对象的属性的内容,应该能对码农们有较大用途。

创新互联成立于2013年,先为顺河等服务建站,顺河等地企业,进行企业商务咨询服务。为顺河企业网站制作PC+手机+微官网三网同步一站式服务解决您的所有建站问题。

class Klass(object):

    def __getattr__(self, name):
        """
        Locate the function with the dotted
        attribute.
        """
        def traverse(parent, child):
            if instance(parent, str):
                parent = getattr(self, parent)
            return getattr(parent, child)
        return reduce(traverse, name.split('.'))

网站标题:python通过点操作符和reduce遍历对象的属性的代码
网页路径:http://6mz.cn/article/gpjhos.html

其他资讯