题解 | #修改属性2#
修改属性2
https://www.nowcoder.com/practice/7831806be5684ad6ac0f8b43e3e3558e
class Employee: def __init__(self,name,salary,age=None): self.name = name self.salary = salary self.age = age def printclass(self): print("{}'salary is {}, and his age is {}".format(self.name,self.salary,self.age)) def hasattr(self): if (self.age == None): print("False") else: #print("True") self.printclass() name = input() salary = input() age = input() e = Employee(name,salary) e.hasattr() e.age = age e.hasattr()