[問題] 多個 Constructor
http://stackoverflow.com/questions/625083/python-init-and-self-what-do-they-do
我按照這邊寫得
class Point:
def __init__(self, x, y):
self._x = x
self._y = y
#!/usr/bin/python
class Point:
def __init__(self,x,y):
self._x=x
self._y=y
def __init__(self):
self._x=self._y=0
p=Point(100,200)
print p._x,p._y
這樣他只會認得 __init__(self)
有人說把parameter包成一個大物件在傳進去...
Python 不支援像c++的多型嗎?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.123.102.254
→
09/08 13:20, , 1F
09/08 13:20, 1F
→
09/08 15:18, , 2F
09/08 15:18, 2F
→
09/08 15:19, , 3F
09/08 15:19, 3F
→
09/08 15:20, , 4F
09/08 15:20, 4F
→
09/08 16:09, , 5F
09/08 16:09, 5F
Python 近期熱門文章
PTT數位生活區 即時熱門文章