标签:blog utf-8 rtl style sel bsp set logs code
#! /usr/bin/env python #! -*- cording:utf-8 -*- class Turtle: def __init__(self,x): self.num=x class Fish: def __init__(self,x): self.num=x class Pool: def __init__(self,x,y): self.turtle=Turtle(x) self.fish=Fish(y) def printname(self): print("水池里共有乌龟 %d 只,小鱼 %d 条"%(self.turtle.num,self.fish.num)) #输出数量 pool=Pool(1,10)#实例化pool pool.printname() class CC: def setxy(self,x,y): self.x=x self.y=y def printxy(self): print(self.x,self.y) dd=CC() dd.__dict__ {} print(CC.__dict__)#输出属性 #属性 dd.setxy(4,5)#4,5只属于实例对象 print(dd.__dict__) #不要使用类属性,用来跟踪一些值
标签:blog utf-8 rtl style sel bsp set logs code
原文地址:http://www.cnblogs.com/aqiuarcadia/p/7352815.html