51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

查看: 3081|回复: 5
打印 上一主题 下一主题

[原创] Day4-5测试积点任务

[复制链接]
  • TA的每日心情
    奋斗
    昨天 10:00
  • 签到天数: 1394 天

    连续签到: 5 天

    [LV.10]测试总司令

    1#
    发表于 2018-3-22 11:09:34 | 显示全部楼层
    class Car:#外部类
        class Door:#内部类
            def open(self):
                print('open door')
            
        class Wheel:
            def run(self):
                print('car run')
                
    if __name__=="__main__":
        car=Car()#实例化外部类
        backDoor=Car.Door()#实例化内部类 第一种方法

        frontDoor=car.Door()#因为car已经实例化外部类,再次实例化Car的内部类 第二种方法
        backDoor.open()
        frontDoor.open()
        wheel=car.Wheel()#car已经实例化外部类,Wheel()再次实例化内部类
        wheel.run()#调用内部类的方法
    回复

    使用道具 举报

    本版积分规则

    关闭

    站长推荐上一条 /1 下一条

    小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

    GMT+8, 2024-5-11 03:00 , Processed in 0.059297 second(s), 21 queries .

    Powered by Discuz! X3.2

    © 2001-2024 Comsenz Inc.

    快速回复 返回顶部 返回列表