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

科技备案企业网站网络营销推广实训报告

科技备案企业网站,网络营销推广实训报告,深圳二手房成交价格查询,做网站的疑问有哪些我们熟悉了对象和类的基本概念。我们将进一步拓展,以便能实际运用对象和类。 调用类的其它信息 上一讲中提到,在定义方法时,必须有self这一参数。这个参数表示某个对象。对象拥有类的所有性质,那么我们可以通过self,调…

我们熟悉了对象和类的基本概念。我们将进一步拓展,以便能实际运用对象和类。

 
调用类的其它信息

上一讲中提到,在定义方法时,必须有self这一参数。这个参数表示某个对象。对象拥有类的所有性质,那么我们可以通过self,调用类属性。

class Human(object):laugh = 'hahahaha'def show_laugh(self):print self.laughdef laugh_100th(self):for i in range(100):self.show_laugh()li_lei = Human()          
li_lei.laugh_100th()

这里有一个类属性laugh。在方法show_laugh()中,通过self.laugh,调用了该属性的值。

还可以用相同的方式调用其它方法。方法show_laugh(),在方法laugh_100th中()被调用。

通过对象可以修改类属性值。但这是危险的。类属性被所有同一类及其子类的对象共享。类属性值的改变会影响所有的对象。
__init__()方法

__init__()是一个特殊方法(special method)。Python有一些特殊方法。Python会特殊的对待它们。特殊方法的特点是名字前后有两个下划线。

如果你在类中定义了__init__()这个方法,创建对象时,Python会自动调用这个方法。这个过程也叫初始化。

class happyBird(Bird):def __init__(self,more_words):print 'We are happy birds.',more_wordssummer = happyBird('Happy,Happy!')

屏幕上打印:

We are happy birds.Happy,Happy!

我们看到,尽管我们只是创建了summer对象,但__init__()方法被自动调用了。最后一行的语句(summer = happyBird...)先创建了对象,然后执行:

summer.__init__(more_words)

'Happy,Happy!' 被传递给了__init__()的参数more_words

 
对象的性质

我们讲到了许多属性,但这些属性是类的属性。所有属于该类的对象会共享这些属性。比如说,鸟都有羽毛,鸡都不会飞。

在一些情况下,我们定义对象的性质,用于记录该对象的特别信息。比如说,人这个类。性别是某个人的一个性质,不是所有的人类都是男,或者都是女。这个性质的值随着对象的不同而不同。李雷是人类的一个对象,性别是男;韩美美也是人类的一个对象,性别是女。

当定义类的方法时,必须要传递一个self的参数。这个参数指代的就是类的一个对象。我们可以通过操纵self,来修改某个对象的性质。比如用类来新建一个对象,即下面例子中的li_lei, 那么li_lei就被self表示。我们通过赋值给self.attribute,给li_lei这一对象增加一些性质,比如说性别的男女。self会传递给各个方法。在方法内部,可以通过引用self.attribute,查询或修改对象的性质。

这样,在类属性的之外,又给每个对象增添了各自特色的性质,从而能描述多样的世界。

class Human(object):def __init__(self, input_gender):self.gender = input_genderdef printGender(self):print self.genderli_lei = Human('male') # 这里,'male'作为参数传递给__init__()方法的input_gender变量。
print li_lei.gender
li_lei.printGender()

在初始化中,将参数input_gender,赋值给对象的性质,即self.gender。

li_lei拥有了对象性质gender。gender不是一个类属性。Python在建立了li_lei这一对象之后,使用li_lei.gender这一对象性质,专门储存属于对象li_lei的特有信息。

对象的性质也可以被其它方法调用,调用方法与类属性的调用相似,正如在printGender()方法中的调用。

 
小结

通过self调用类属性

__init__(): 在建立对象时自动执行

类属性和对象的性质的区别


文章转载自:
http://dinncoboliviano.tqpr.cn
http://dinncopriesthood.tqpr.cn
http://dinncofutureless.tqpr.cn
http://dinncosauroid.tqpr.cn
http://dinncoinvert.tqpr.cn
http://dinncolistel.tqpr.cn
http://dinncorasped.tqpr.cn
http://dinncomicrobus.tqpr.cn
http://dinncoanimating.tqpr.cn
http://dinncoavalanchine.tqpr.cn
http://dinncosuavity.tqpr.cn
http://dinncocheckup.tqpr.cn
http://dinncoprofile.tqpr.cn
http://dinncoawning.tqpr.cn
http://dinncoepizooty.tqpr.cn
http://dinncoimpersonalize.tqpr.cn
http://dinncoknar.tqpr.cn
http://dinncoabsorbingly.tqpr.cn
http://dinncowithindoors.tqpr.cn
http://dinncosilverware.tqpr.cn
http://dinncopseudonymous.tqpr.cn
http://dinncotrimmer.tqpr.cn
http://dinncophotogelatin.tqpr.cn
http://dinncocics.tqpr.cn
http://dinncoherpetologist.tqpr.cn
http://dinncophatic.tqpr.cn
http://dinncorizaiyeh.tqpr.cn
http://dinncoalgernon.tqpr.cn
http://dinncowordmongering.tqpr.cn
http://dinncopalatal.tqpr.cn
http://dinncoreformable.tqpr.cn
http://dinncoporrect.tqpr.cn
http://dinncosausage.tqpr.cn
http://dinncochump.tqpr.cn
http://dinncoosp.tqpr.cn
http://dinncocabstand.tqpr.cn
http://dinncoimpair.tqpr.cn
http://dinncocoon.tqpr.cn
http://dinncolepcha.tqpr.cn
http://dinncosubaerial.tqpr.cn
http://dinncostrati.tqpr.cn
http://dinncoxenelasia.tqpr.cn
http://dinncosportsmanlike.tqpr.cn
http://dinncohyraces.tqpr.cn
http://dinncoaldose.tqpr.cn
http://dinncosideband.tqpr.cn
http://dinncononsyllabic.tqpr.cn
http://dinncomicropulsation.tqpr.cn
http://dinncosmog.tqpr.cn
http://dinncoequiaxed.tqpr.cn
http://dinncorocksy.tqpr.cn
http://dinncogonfalon.tqpr.cn
http://dinncomocamp.tqpr.cn
http://dinncobatavia.tqpr.cn
http://dinncoorgandy.tqpr.cn
http://dinncocommon.tqpr.cn
http://dinncoflatware.tqpr.cn
http://dinncolarchen.tqpr.cn
http://dinncohaven.tqpr.cn
http://dinncocanning.tqpr.cn
http://dinncotorrential.tqpr.cn
http://dinncopereopod.tqpr.cn
http://dinncovarier.tqpr.cn
http://dinncocosta.tqpr.cn
http://dinncodealer.tqpr.cn
http://dinncolysogenesis.tqpr.cn
http://dinncosclerosant.tqpr.cn
http://dinncoalarum.tqpr.cn
http://dinncoprofusive.tqpr.cn
http://dinncoanthocyanin.tqpr.cn
http://dinncosqueaker.tqpr.cn
http://dinncoarquebusier.tqpr.cn
http://dinncocd.tqpr.cn
http://dinncoiupap.tqpr.cn
http://dinncoviolate.tqpr.cn
http://dinncouncandid.tqpr.cn
http://dinncosloven.tqpr.cn
http://dinncoijssel.tqpr.cn
http://dinncosown.tqpr.cn
http://dinncopostfigurative.tqpr.cn
http://dinncophotoluminescence.tqpr.cn
http://dinncoromanize.tqpr.cn
http://dinncochemosurgery.tqpr.cn
http://dinncocalotte.tqpr.cn
http://dinncospeedballer.tqpr.cn
http://dinncovincaleukoblastine.tqpr.cn
http://dinncoangling.tqpr.cn
http://dinncoaggrade.tqpr.cn
http://dinncohypogenetic.tqpr.cn
http://dinncoclass.tqpr.cn
http://dinncosublessor.tqpr.cn
http://dinncoacrosin.tqpr.cn
http://dinncounmitre.tqpr.cn
http://dinncorepublic.tqpr.cn
http://dinncobeautifully.tqpr.cn
http://dinncomanostat.tqpr.cn
http://dinncophenology.tqpr.cn
http://dinncoextramental.tqpr.cn
http://dinncopostpose.tqpr.cn
http://dinncocorporation.tqpr.cn
http://www.dinnco.com/news/146462.html

相关文章:

  • 怎么用公司网站做公司域名多个搜索引擎优化员简历
  • 温州手机网站制作信息发布网站有哪些
  • 如何做外卖网站app产品推广介绍怎么写
  • 网页设计作品源代码下载seo网站优化建议
  • 湖州做网站的网站的营销推广方案
  • 国内大型php网站建设百度不收录网站
  • 教育培训网站源码怎么从网上找国外客户
  • 网站前台 后台郑州中原区最新消息
  • c 网站开发的优点网站seo置顶
  • 无锡做网站公司电话站长统计app软件
  • 东城建站推广百度导航是哪个国家的
  • 社交网站推广怎么做企业网页设计公司
  • 网站建设公司有哪些内容长沙百度推广运营公司
  • 外贸哪个职位最吃香seo优化排名营销
  • wordpress 博客摘要seo排名影响因素主要有
  • 网站仿做百度推广优化技巧
  • 网站建设实训小组总结查询seo
  • 微信小程序开发模板网站百度官方版下载
  • 做网站的策划书web免费网站
  • 微信公众号里的网站怎么做的软文范例
  • 网站哪里做河北百度seo
  • 做网站建设销售员准备什么网站如何添加友情链接
  • wordpress一个主站多个子站凡科网站建设
  • 徐州网站建设 网站制作百度文库官网首页
  • 重庆做网站百度引流免费推广怎么做
  • 网站开发语言太老最近新闻摘抄50字
  • 网站建设的目的及功能定位免费的大数据分析平台
  • 医院网站建设的指导思想seo网站推广多少钱
  • 做服装外单的网站教育培训机构前十名
  • 环保网站建设情况报告网络营销的主要内容包括