我試圖教自己Python,並且大部分都做得很好。然而,當我嘗試運行代碼Python錯誤:未定義全局名稱
class Equilateral(object):
angle = 60
def __init__(self):
self.angle1, self.angle2, self.angle3 = angle
tri = Equilateral()
我得到以下錯誤:
Traceback (most recent call last):
File "python", line 15, in <module>
File "python", line 13, in __init__
NameError: global name 'angle' is not defined
有可能是一個非常簡單的答案,但爲什麼會出現這種情況?