When __repr__() is called?

前端 未结 4 1015
轻奢々
轻奢々 2021-01-17 10:08

print OBJECT calls OBJECT.__str__(), then when OBJECT.__repr__() is called? I see that print OBJECT calls OBJECT.__

4条回答
  •  说谎
    说谎 (楼主)
    2021-01-17 11:07

    In python 2.x, `obj` will end up calling obj.__repr__(). It's shorthand for repr().

提交回复
热议问题