python类的对象使用
class student():
def __init__(self,age,sex):
self.age = age
self.sex = sex #self.__sex =sex 表示私有化
def missing(self):
if self.age =='':
print("no")
else:
print("yes")
class person():
def __init__(self):
self.age = 18.0
self.sex = 'm'
self.gradyer = 2006
def p(self):
print(self.age)
p1 = person()
p1.p()
print(p1.sex)
耐得住寂寞,才能登得顶
Gitee码云:https://gitee.com/lyc96/projects