Discuss / Python / str

str.py中去掉repr=str ,程序还是可正常运行 拿这一行的作用是什么

看了后面忘了前面吗

守候986

#3 Created at ... [Delete] [Delete and Lock User]

__repr()是为调试服务的 如果没有__repr() = __str__ 在交互式环境下打印的结果就又变成:

<__main__.Student object at 0x109afb190>


  • 1

Reply