题解 | #多部门的打工人#
多部门的打工人
https://www.nowcoder.com/practice/e704f2c5c30c4aa0b1de9e71bc584fb3
class Nowcoder: def __init__(self, name, ID,num): self.name=name self.ID = ID self.num=num def printinfomation(self): print( "{}'s ID is {}, and his or her number of signing in is {}.".format(self.name,self.ID,self.num) ) class IT(Nowcoder): def __init__(self, name, ID, num, language): super().__init__(name, ID, num) self.language=language def lan(self): print(self.language) class Designer(Nowcoder): def __init__(self, name, ID, num, color): super().__init__(name, ID, num) self.color=color def colora(self): print(self.color) info1=input().split() info2=input().split() itniuma=IT(name=info1[0],ID=info1[1],num=info1[2],language=info1[3]) itniuma.printinfomation() itniuma.lan() designniuma=Designer(name=info2[0],ID=info2[1],num=info2[2],color=info2[3]) designniuma.printinfomation() designniuma.colora()
牛牛知识快记:
1、format输出格式化
2、子类父类
3、super()函数在子类中用父类