6.29一个_rcv 面试题

#coding:utf-8

#2018-6-29 16:30:34
#类调用属性,属性没有,用__getatrr__魔法方法!
#目的打印出 think different itcast

class Foo(object):
    """ """
    def  __init__(self):
        pass

    def __getattr__(self,item):
        print(item, end="")
        return self
    def __str__(self):
        return ""

print(Foo().think.different.itcast)

 

posted @ 2018-06-29 17:14  我想喝杨枝甘露~  阅读(153)  评论(0编辑  收藏  举报