标签:r类和对象
class Student(object): """docstring for Student""" def __init__(self, name, age, score,): self.name = name self.age = age self.score = score def get_level(self): if self.score > 90: return self.name+"A" elif self.score > 70: return self.name+"B" else: return self.name+"c" lisa = Student(‘lisa‘,‘18‘,99) suki = Student(‘suki‘,‘10‘,76) tom = Student(‘tom‘,‘103‘,55) print(lisa.get_level()) print(suki.get_level()) print(tom.get_level())
标签:r类和对象
原文地址:http://sukijia.blog.51cto.com/12572579/1898194