class Employee:
    def __init__(self, name, salary):
        self.name = name
        self.salary = salary

    def printclass(self):
        try:
            print(f"{self.name}'salary is {self.salary}, and his age is {self.age}")
        except AttributeError:
            print("Error! No age")

# 读取输入
name = input()
salary = int(input())
age = int(input())

# 创建实例
e = Employee(name, salary)

# 第一次调用,没有 age,应该输出错误提示
e.printclass()

# 添加 age 属性
e.age = age

# 第二次调用,输出完整信息
e.printclass()

注意Python类的动态调用属性!!!