看板 Python 關於我們 聯絡資訊
Hi. 我是新手中的新手 我目前按照 http://pydoing.blogspot.com/2008/10/blog-post_1288.html 了解Python 以下是CODE: class Point(object): def _init_(self,x=0,y=0): self.x=x self.y=y def _str_(self): return "("+str(self.x)+","+str(self.y)+")" 先編譯後 在Python Shell下輸入p1=Point(1,1) 卻出現 Traceback (most recent call last): File "<pyshell#20>", line 1, in <module> p=Point(1,1) TypeError: object.__new__() takes no parameters 哪裡的問題呢?我對照這個教學的內容照著打上的 感謝大家寶貴的時間啦~ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 71.196.234.172
AndCycle:是 __init__ 不是 _init_ 10/09 14:29
qetuomj:原來,網頁上寫連續兩個底線,真是閱讀不仔細。感謝!! 10/09 14:34