您的位置:首页 > 编程语言 > Python开发

python面向对象初探

2017-11-05 00:38 316 查看
class Student(object):     def __init__(self,name,score):
        self.name=name
        self.score=score     def print_score(self):
        print '%s: %s' %(self.name,self.score)
bart=Student('bart','98')
kali=Student('kaili','100')
bart.print_score()
kali.print_score() python中面向对象和Java类似,都需要考虑作为对象后所具有的属性,例如学生的学号,性别等
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: