Python学习笔记(二十二)——小甲鱼第四十三讲

0、不会

 

1、对于a+b,如果a对象的__add__方法没有实现或者不支持相应操作,Python会自动调用b的__radd__方法

 

2、使用super()这个函数

 

3、为基类起别名,在类定义的时候,使用别名代替你要继承的基类

 

4、在类中直接定义的(没有self)变量就是静态属性

 

5、静态方法只需要在普通方法前边加上@staticmethod修饰符即可

 

 

0、

class A:

    def __init__(self,*arg):

        if not arg:

            print('并没有传入参数')

        else:

            print('传入了%d个参数' % (len(arg)))

            for each in arg:

                print(each,end='')

 

               

>>> a=A(1,2,3)

传入了3个参数

123

 

1、

class word(str):

    def __gt__(self,other):

        return len(self) > len(other)

    def __lt__(self,other):

        return len(self) < len(other)

    def __ge__(self,other):

        return len(self) >= len(other)

    def __le__(self,other):

        return len(self) <= len(other)

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值