您的位置:首页 > 编程语言 > Python开发

《笨办法学 Python》 学习笔记05 —— Class

2011-10-15 20:41 337 查看
Class

class TheThing(object):

def __init__(self):
self.number = 0

def some_function(self):
print "I got called."

def add_me_up(self, more):
self.number += more
return self.number

# two different things
a = TheThing()
b = TheThing()

a.some_function()
b.some_function()

print a.add_me_up(20)
print b.add_me_up(30)

print a.number
print b.number
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: