运算符在Python类上的重载(repr)[关闭]

问题描述 投票:0回答:1
class Employee:


def __init__(self,name):
    self.name=name


    def __repr__(self):
        return self.name

t1=Employee("lol")
print(t1)        

[[Out]:<< [main。雇员对象位于0x000001AA6098FB08>

我想让Out成为:“ lol”
python class oop subclass
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.