当前位置: 首页 > news >正文

浙江天奥建设集团网站网站布局选择

浙江天奥建设集团网站,网站布局选择,优创智汇高端网站建设电话怎么样,wordpress修改作者链接今天学习的内容#xff1a;1.面向对象编程的概念1)面向对象的三个基本特征#xff1a;封装、继承、多态2)类和对象是面向对象编程的2个主要方面。类使用class关键字创建。类的域和方法被列在一个缩进块中。2.类[rootreed 0504]# cat simpleclass.py#!/usr/bin/pythonclass Pe…今天学习的内容1.面向对象编程的概念1)面向对象的三个基本特征封装、继承、多态2)类和对象是面向对象编程的2个主要方面。类使用class关键字创建。类的域和方法被列在一个缩进块中。2.类[rootreed 0504]# cat simpleclass.py#!/usr/bin/pythonclass Person:pass #an empty block# print my name is reedpPerson()print p[rootreed 0504]# ./simpleclass.py3.对象的方法[rootreed 0504]# cat method.py#!/usr/bin/pythonclass Person:def sayHi(self):print hello,my name is reedpPerson()p.sayHi()[rootreed 0504]# ./method.pyhello,my name is reed4.__init__方法__init__方法在类的一个对象被建立时马上运行。这个方法可以用来对你的对象做一些你希望的 初始化 。注意这个名称的开始和结尾都是双下划线。[rootreed 0504]# cat class_init.py#!/usr/bin/pythonclass Person:def __init__(self,name):self.namenamedef sayHi(self):print hello,my name is,self.namepPerson(reed)p.sayHi()[rootreed 0504]# ./class_init.pyhello,my name is reed5.类与对象的方法[rootreed 0504]# cat objvar.py#!/usr/bin/python#filename:objvar.pyclass Person:population0def __init__(self,name):self.namenameprint (initializing %s)%self.name#when this person is created,he/she adds to the populationPerson.population1def __del__(self):print %s says bye%self.nameself.__class__.population-1if self.__class__.population0:print i am the last oneelse:print there are still %d people left%Person.populationdef sayHi(self):print hi,my name is %s%self.namedef howMany(self):if Person.population1:print i am the only person hereelse:print we have %d persons here%Person.populationswaroopPerson(swaroop)swaroop.sayHi()swaroop.howMany()print --------------reedPerson(reed)reed.sayHi()reed.howMany()print --------------deerPerson(deer)deer.sayHi()deer.howMany()print --------------swaroop.sayHi()swaroop.howMany()[rootreed 0504]# ./objvar.py(initializing swaroop)hi,my name is swaroopi am the only person here--------------(initializing reed)hi,my name is reedwe have 2 persons here--------------(initializing deer)hi,my name is deerwe have 3 persons here--------------hi,my name is swaroopwe have 3 persons heredeer says byethere are still 2 people leftswaroop says byethere are still 1 people leftreed says byei am the last one6.继承继承完全可以理解成类之间的类型和子类型的关系[rootreed 0504]# cat inherit.py#!/usr/bin/python#filenameinherit.pyclass SchoolMember:def __init__(self,name,age):self.namenameself.ageageprint Initialized SchoolMember:%s%self.namedef tell(self):print Name:%sAge:%s%(self.name,self.age)class Teacher(SchoolMember):def __init__(self,name,age,salary):SchoolMember.__init__(self,name,age)self.salarysalaryprint Initalized Teacher:%s%self.namedef tell(self):SchoolMember.tell(self)print Salary:%d%self.salaryclass Student(SchoolMember):def __init__(self,name,age,marks):SchoolMember.__init__(self,name,age)self.marksmarksprint Initialized Student:%s%self.namedef tell(self):SchoolMember.tell(self)print Marks:%d%self.markstTeacher(Mrs.Reed,40,30000)t.tell()sStudent(Lemon,22,75)s.tell()[rootreed 0504]# ./inherit.pyInitialized SchoolMember:Mrs.ReedInitalized Teacher:Mrs.ReedName:Mrs.ReedAge:40Salary:30000Initialized SchoolMember:LemonInitialized Student:LemonName:LemonAge:22Marks:757__del__方法在对象消逝的时候被调用
http://www.sadfv.cn/news/388599/

相关文章:

  • 请公司做网站没有做好可以退钱吗网站开发代理招商
  • 刷q币网站建设网站建设系统多少钱
  • 做网站顶部图片长度是多少网站建设的关键点
  • 网站引导动画怎么做的html5的网站设计
  • 网络推广网站河南重庆公司注册网站
  • 泉州企业网站建设国外ui设计网站
  • 河南省住房和城乡建设厅网站建立企业的网站有哪几种方案
  • 网站建设需要写代码吗网站二级域名解析
  • 怎么做废品收购网站WordPress底部添加运行时间
  • 设计的网站有哪些高端企业网站建站
  • 网站建设系统 网站自助建站系统盐城网站开发如何
  • 网站设计的价格青岛seo整站优化招商电话
  • 新华网两学一做专题网站网站做seo推广 s
  • 义乌网站建设制作商宁夏建设工程招标投标信息网站
  • 微商网站如何做推广网络推广有哪些方法
  • 中国风古典网站模板常州网红打卡景点
  • 可以看封禁网站的浏览器石家庄网络推广
  • 特产电商网站建设报价单wordpress保存图片插件
  • 之梦网站怎么做seo济南网站建设策划方案
  • 网站如何做中英文双语言哈尔滨做网站价格
  • 企业如何做好网站的seo优化wordpress 文章目录插件
  • 广州百度推广排名优化wordpress打开速度优化
  • icp备案是网站上线前网页设计素材收集
  • 最专业网站建设公司首选商品网站做推广方案
  • 软件最全的网站百度小程序怎么删除
  • 文化网站开发背景产品营销策略
  • asp.net企业门户网站源码简述jsp网站架构
  • 建站设计公司山西网络公司公司
  • 适用于建设微型网站开发wordpress
  • 江苏建设省直报名网站公司装修设计哪家好