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类似,都需要考虑作为对象后所具有的属性,例如学生的学号,性别等
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类似,都需要考虑作为对象后所具有的属性,例如学生的学号,性别等
相关文章推荐
- python面向对象初探
- Python基础—面向对象(进阶篇)
- Python(面向对象)
- Python面向对象之接口、抽象类与多态详解
- Python 面向对象(初级篇)
- Python入门——面向对象(1)
- Python面向对象6:isinstance、super、有序字典
- Python入门——面向对象(1)
- python+apache初探
- Python基础08 面向对象的基本概念
- 用Python做数据分析初探(一)
- Python 3.0 面向对象
- Python面向对象详解
- Python缓冲池初探
- 初探python对象复制问题的深拷贝和浅拷贝
- python面向对象
- python面向对象(二)——类成员
- Python 面向对象 基础
- python之面向对象进阶
- python面向对象