摘要: class Foo: def __init__(self,name): self.name = name def __getitem__(self,item): print('getitem') print(item) return self.__dict__.get[item] def __set 阅读全文
posted @ 2022-10-22 19:58 ty1539 阅读(16) 评论(0) 推荐(0) 编辑
摘要: class People(object): color = 'yellow' #这就是一个公有属性,可以在类里和类外调用 __age = 30 #这就是一个私有属性,只能在类里调用。 def think(self): self.color = "black" print ("i am a %s" % 阅读全文
posted @ 2022-10-22 19:56 ty1539 阅读(16) 评论(0) 推荐(0) 编辑
摘要: class People(object): color = "yellow" __age = 30 #私有属性 def think(self): self.color = "black" print("I am a %s" %self.color) print(self.__age) def __t 阅读全文
posted @ 2022-10-22 19:56 ty1539 阅读(16) 评论(0) 推荐(0) 编辑
摘要: #_*_ encoding: utf-8 _*_ @author: ty hery 2018/9/6 def printStar(intNum): s = "*" spaceLength = intNum blockCount = int(intNum / 2 + 1) for i in range 阅读全文
posted @ 2022-10-22 11:03 ty1539 阅读(11) 评论(0) 推荐(0) 编辑