python实例化时报错
class Settings:
"""存储《外星人》的所有设置的类"""
def _init_(self):
"""初始化游戏的设置"""
# 屏幕设置
self.screen_width = 900
self.screen_height = 600
self.bg_color = (230, 230, 230)
通过settings = Settings()
实例化Settings时报:AttributeError: 'Settings' object has no attribute 'screen_width'
原因是__init__(self)
中的init
前后只写了一根下划线,正确的应该是2根