TypeError: this constructor takes no arguments

来源:互联网 发布:商家怎么投诉淘宝小二 编辑:程序博客网 时间:2024/06/03 18:29

from graphics import*
class child:
    def _init_(self,win,center,radius,color):
        self.w=win
        self.p=center
        self.r=radius
        self.c=color
    def show(self):
        c=Circle(self.p,self.r)
        c.setFill(self.c)
        c.draw(self.w)
    def setColor(self,color):
        self.c=color
        c.setFill(self.c)
       
from graphics import*
def main():
    w=GraphWin()
    A=child(w,Point(50,40),30,'blue')
    A.show()
    w.getMouse()
    w.close()
   
main()
#TypeError: this constructor takes no arguments

 

错误原因:

构造函数,是两个下划线,不是一个!

 

0 0
原创粉丝点击