2006年04月28日 星期五 21:57
if __name__=='__main__': print Aclass().foo(100) ======= 2006-04-28 19:38:23 您在来信中写道:======= >#!/usr/bin/python >import sys >import math >class Aclass(object): > def __init__(self,x): > self.x=x > def foo(self,x): > return self.x*self.x-6*self.x+9 >if __name__=="__main__": > print Aclass.foo(100) >为什么这样的调用总是报错; >TypeError: unbound method foo() must be called with Aclass instance as >first argument (got int instance instead) >_______________________________________________ >python-chinese >Post: send python-chinese at lists.python.cn >Subscribe: send subscribe to python-chinese-request at lists.python.cn >Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn >Detail Info: http://python.cn/mailman/listinfo/python-chinese = = = = = = = = = = = = = = = = = = = = 致 礼! zenghz huazhongscut at 163.com 2006-04-28
Zeuux © 2025
京ICP备05028076号