请帮帮忙
class ScrollingCredits:
def __init__(self):
self.load_credits('assignment.txt')
(self.background, self.background_rect) = \
load_image('starfield.gif', True)
self.font = pygame.font.Font(None, FONT_SIZE)
self.scroll_speed = SCROLL_SPEED
self.scroll_pause = SCROLL_PAUSE
self.end_wait = END_WAIT
self.reset()
def load_credits(self, filename):
f = open(filename)
credits = []
while 1:
line = f.readline()
if not line:
break
line = string.rstrip(line)
credits.append(line)
f.close()
self.lines = credits
我收到以下错误
line 66, in __init__
self.load_credits('assignment.txt')
AttributeError: 'ScrollingCredits' object has no attribute 'load_credits'
我想知道它是否可能是assignmentidertxt,但我不是100%,我谷歌了一下,但我似乎找不到解决方案,帮助将非常感激
1条答案
按热度按时间eaf3rand1#
正如Wondercricket的注解所建议的,您应该减少
load_credits
的缩进。正确的代码是: