class Employee: def __init__(self, name, salary): self.name = name self.salary = int(salary) # 将输入的字符串转换为整数 def printclass(self): try: self.age except AttributeError: print("Error! No age") else: print("{}'salary is {}, and his age is {}".format(self.name, self.salary, self.age)) name = input() salary = int(input()) # 将输入的字符串转换为整数 e = Employee(name, salary) print(hasattr(e, 'age')) e.age = int(input()) # 将输入的字符串转换为整数 e.printclass()