当前位置 : 主页 > 编程语言 > python >

Python面向对象之封装

来源:互联网 收集:自由互联 发布时间:2022-08-10
#__author__ = 'DouYunQian' #coding = utf - 8 '' ' Python ?? ?? ?? ?? ?? '' ' class C1 : def __init__ ( self , name , obj ): self . name = name self . obj = obj class C2 : def __init__ ( self , name , age ): self . name = name self . age = a
#__author__ = 'DouYunQian'

#coding=utf-8

'''

Python??????????

'''

class C1:

def __init__(self,name,obj):

self.name=name

self.obj=obj

class C2:

def __init__(self,name,age):

self.name=name

self.age=age

N1=C2("alex",18)

N2=C1("good",N1)

print(N2.obj.age)
上一篇:Python第5天--函数
下一篇:没有了
网友评论