Python自定义的类,为何须要重写__str__

首先,自定义的类在不继承任何基类的状况下,也具备__str__属性:python class RoundFloatManual(object): ... def __init__(self, val): ... assert isinstance(val, float), \ ... "Value must be a float!" ...
相关文章
相关标签/搜索