[問題] Class 範例,不知道哪出錯
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
推
10/09 14:29, , 1F
10/09 14:29, 1F
→
10/09 14:34, , 2F
10/09 14:34, 2F
Python 近期熱門文章
PTT數位生活區 即時熱門文章