2024-10-03 21:30:02 发布
网友
class Employee: def __init__(self,first,last,salary): self.first = first self.last = last self.salary = salary emp_1 = Employee("Rohan","Parab",100000) print(emp_1)
您需要实现__str__方法,否则它将打印(正如您可能观察到的)对象位置
__str__
例如:
def __str__(self): return f"First Name: {self.first}, Last Name {self.last}, Salary {self.salary}"
您需要实现
__str__
方法,否则它将打印(正如您可能观察到的)对象位置例如:
相关问题 更多 >
编程相关推荐