Python字符串到类

时间:2014-12-15 07:56:30

标签: python class python-2.7 printing

我们可以更改类字符串的输出吗?注意:我说的是不是实例的课程

例如:

class Foo(object):
    baz=10
    def __init__(self,value):
        self.value=value

    def bar(self):
        self.a="3llo world"

    def __str__(self):
        return "not me"

    def __repr__(self):
        return "not me either"

print Foo

输出:

<class '__main__.Foo'>

输出来自哪里?感谢

0 个答案:

没有答案