随笔分类 - Python
摘要:__getitem__,__setitem__,__delitem__ 类似 attr 方法,不同的是item方法使用【】
阅读全文
摘要:#封装:区分内外,使得外部不能直接看到内部具体信息,但内部可以正常看到 class People: _star = "earth" #在类中以单下划线开头的属性,按照约定是作为隐藏的属性,为私有的,类的外部是不应该调用的 __country = "china" #在类中以双下划线开头的属性,Pyth
阅读全文
摘要:class Room: tag = 1 def __init__(self,owner,name,width,length): self.Owner = owner self.Name = name self.Width = width self.Length = length @property
阅读全文
摘要:#面向对象设计(ood) def person(name,age,action): #做一个对象和行为关联性,通过作用域来限制其他的对象不可调用该对象的行为 #初始化设置 def init(name,age,action): #风湿理论 per = { #字典存放对象和行为 "name":name,
阅读全文

浙公网安备 33010602011771号