首页 > 其他 > 详细

爬虫的子父类

时间:2019-08-12 21:01:50      阅读:408      评论:0      收藏:0      [点我收藏+]

栗子:编程开发人员学 Python 的话,学习效率很高,默认为1。
          而且,job 的属性为 programmer。
class Student:

    def __init__(self,name,job=None,time=0.00,time_effective=0.00):

        self.name=name

        self.job=job

        self.time=time

        self.time_effective=time_effective

    def count_time(self,hour,rate):

        self.time+=hour

        self.time_effective+=hour*rate

class Programmer(Student):

    def __init__(self,name):

        Student.__init__(self,name,job=‘programmer‘,time=0.00,time_effctive=0.00)

    def count_time(self,hour):

        Student.count_time(self,hour,rate=1)

student1=Student(‘韩梅梅‘)

student2=Programmer(‘李华‘)

print(student1.job)

print(student2.job)

student1.count_time(10.0,0.8)

student2.count_time(10)

print(student1.time_effective)

print(student2.time_effective)

爬虫的子父类

原文:https://www.cnblogs.com/Macfee/p/11342226.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!