_repr__ and __str__ are two methods for displaying the
__str__ is user-oriented, the value is converted to a string suitable for human reading
__repr__ oriented programmers, the value is read into interpreter for take the form of a string
class House(object):
def __init__(self, new_name, new_age):
self.name = new_name
self.age = new_age
def __str__(self):
return "%s的年龄%d" % (self.name, self.age)
def __repr__(self):
return "%s的年龄%d" % (self.name, self.age)
chitu = House('chitu', 30)
print(chitu)