题解 | #修改属性1#

修改属性1

https://www.nowcoder.com/practice/c5ab441e5e8f4ec7bf36ba51a3141340

class Employee():
    def __init__(self,name,salary) -> None:
        self.name = name
        self.salary = salary
    
    def printclass(self):
        try:
            print("{}'salary is {}, and his age is {}".format(self.name,self.salary,self.age))
        except Exception:
            print("Error! No age")
    


name=input()
salary = int(input())
age = int(input())

e = Employee(name,salary)
e.printclass()
e.age = age
e.printclass()

全部评论

相关推荐

网安已死趁早转行:山东这地方有点说法
点赞 评论 收藏
分享
咩咩子_:项目和图形引擎岗没啥关系,最好还是项目和岗位有相关度好点,不然真有面也不一定会问很多
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务