首页 > 其他 > 详细

面向对象的类

时间:2017-11-30 00:07:06      阅读:269      评论:0      收藏:0      [点我收藏+]
class Student:   # declare the class
__abc=1111111
def __init__(self,name,age,sex,grade,landname,pwd):
self.name=name
self.age=age
self.sex=sex
self.grade=grade
self.landname=landname
self.__pwd=pwd #creat private variable
def behavior(self):
print("Hi,how are you?")
def print_Student_info(self):
print("\nThe infomation of "+self.name+" is:",self.name,self.age,self.sex,self.grade)
def print_count_info(self):
print("\nLand_name:"+self.name+"\nPassword:"+self.__pwd )
def dispPwd(self):
return self.__abc
#h=Sayhi() #creat object
#h.Sayhello() #calling mathod of the class

#input student variable argument info(name age sex grade landname pwd)
# a=322
# b=222
Tom=Student
Tom=Student("Tom","12","F","98","tom","854xxx")
Tom.name
Tom.behavior()
Tom.print_Student_info()
Tom.print_count_info()

#print Tom._pwd
#print Tom.dispPwd()

面向对象的类

原文:http://www.cnblogs.com/phahap/p/7923283.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!