Python学习——Class类
来源:互联网 发布:安卓淘宝引流量软件 编辑:程序博客网 时间:2024/06/05 02:34
如下代码是对python中类的基本语法的学习:
#基类class info: name='' age=0 #私有属性 __weight=0 def __init__(self,name,age,weight): self.name=name self.age=age self.__weight=weight def speak(self): print('{0} says: I\'m {1},{2}'.format(self.name,self.age,self.__weight))#单继承class student(info): grade='' def __init__(self,name,age,weight,grade): info.__init__(self,name,age,weight) self.grade=grade def speak(self): print('{0} says: I\'m {1} years old, and I\'m in Grade {2}'.format(self.name,self.age,self.grade))class learn(): name='' title='' def __init__(self,name,title): self.name=name self.title=title def speak(self): #将类方法私有化 #def __speak(self): print('I\'m {0}, I want to learn {1}'.format(self.name,self.title))#多继承class inherit(learn,info): def __init__(self,name,age,weight,grade,title): info.__init__(self,name,age,weight) learn.__init__(self,name,title) #def speak(self): # print('我将方法重写了')x=inherit('jack',17,120,9,'python')x.speak()
阅读全文
0 0
- Python学习——Class类
- Python基础学习篇—类(Class)
- python类class学习笔记
- python基础学习-类(class)
- 《笨办法学 Python》 学习笔记05 —— Class
- python 学习笔记——set() class 集合类型
- python学习笔记-10(类class)
- 十五、python class 类学习笔记
- Python学习笔记:类(class)
- Python 学习之类(Class)
- Python 学习笔记:class
- 「学习笔记——Python」Google's Python Class 学习笔记
- Python之类(Class)的学习
- python 学习之---class (inheritance)
- python学习笔记1---class
- python学习之路八--类(class)
- python - 类 class
- Python:class类
- 统计学习方法学习笔记1:统计学习方法概论
- js 之 setTimeout 0 分析
- 2.5音频编辑软件&2.6语音识别技术
- Eclipse安装教程
- ## centos实现https ##
- Python学习——Class类
- CCF认证2017-9 除法
- 重启了Linux ,然后 启动MySQL 出现 Starting MySQL….. ERROR! The server quit without updating PID file
- redis客户端与服务端连接
- TCPSocket
- 深入了解Java爬虫的运用技术
- 安装ubuntu16.04.3单系统-开机显示no boot devices found
- Java(4-2)
- Java web连数据库的案例