python 类

(正确方式)
>>> class a():
    def b(self):
        print "ok"
>>> c = a()
>>> c.b()
ok


(错误方式)
>>> class a():
    def b(self):
        print "ok"
>>> a.b()

Traceback (most recent call last):
  File "<pyshell#66>", line 1, in <module>
    a.b()
TypeError: unbound method b() must be called with a instance as first argument (got nothing instead)

posted @ 2009-11-23 10:06  kid的笔记本  阅读(231)  评论(0编辑  收藏  举报