01.class BB:
02. def printBB():
03. print("no zuo no die")
04.
05.>>> bb = BB()
06.>>> bb.printBB()
07.Traceback (most recent call last):
08. File "<pyshell#8>", line 1, in <module>
09. bb.printBB()
10.TypeError: printBB() takes 0 positional arguments but 1 was given
因为 Python 严格要求方法需要有实例才能被调用,这种限制其实就是 Python 所谓的绑定概念。所以 Python 会自动把 bb 对象作为第一个参数传入,所以才会出现 TypeError:“需要 0 个参数,但实际传入了 1 个参数“。