zoukankan      html  css  js  c++  java
  • 多态与多态性

    '''
    多态:同一种事物的多种形态
    '''
    # import abc
    # class Animal(metaclass=abc.ABCMeta):
    # @abc.abstractmethod
    # def speak(self):
    # pass
    # class Pig(Animal):
    # def speak(self):
    # print('哼哼')
    # class Dog(Animal):
    # def speak(self):
    # print('汪汪')
    # class People(Animal):
    # def speak(self):
    # print('hello')
    #
    # people1=People()
    # dog1=Dog()
    # pig1=Pig()
    '''
    多态性:在不考虑对象具体类型的情况下,直接使用对象
    '''
    # people1.speak()
    # dog1.speak()
    # pig1.speak()
    '''
    hello
    汪汪
    哼哼
    '''
    # def talk(obj):
    # obj.speak()
    # talk(people1)
    # talk(pig1)
    # talk(dog1)
    '''
    hello
    哼哼
    汪汪
    '''
    # l=list([1,2,3])
    # s=str('hello')
    # t=tuple((1,'a',3,'b',5,'c'))
    # l.__len__()
    # s.__len__()
    # t.__len__()
    # print(len(l))
    # print(len(s))
    # print(len(t))
    '''
    3
    5
    6
    '''
  • 相关阅读:
    Mybatis连接配置文件详解
    MyBatis映射配置文件详解
    AGC 016 C
    CodeForces
    UVA
    某5道CF水题
    DZY Loves Chinese / DZY Loves Chinese II
    [SHOI2016] 黑暗前的幻想乡
    CodeForces
    CodeForces
  • 原文地址:https://www.cnblogs.com/0B0S/p/12089810.html
Copyright © 2011-2022 走看看