class Student(object):
def __init__(self,name,score):
self.name=name
self.score=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()
print '%s: %s' %(self.name,self.score)
bart=Student('bart','98')
kali=Student('kaili','100')
bart.print_score()
kali.print_score()
python中面向对象和Java类似,都需要考虑作为对象后所具有的属性,例如学生的学号,性别等