-1
나는 그래서 게임이 켜집니다 보드를 짓고 있어요 박하 사탕 정면 게임을 만들려고 정의 경우에도 AttributeError를 제기하지만, 나는이 오류 받고 있어요 :인스턴스 메소드는 속성이
Traceback (most recent call last):
File "python", line 18, in <module>
File "python", line 10, in display
AttributeError: 'Board' object has no attribute 'cells
을
는
import os #try to import the clode to the operating system, use import
os.system('clear')
# first: Build the board
class Board(): #use class as a templete to create the object, in this case the board
def _init_(self):
self.cells = [' ', ' ', ' ' , ' ', ' ', ' ' , ' ', ' ', ' '] #will use self to define the method, in this case the board cells
def display(self):
print ('%s | %s | %s' %(self.cells[1] , self.cells[2] , self.cells[3]))
print ('_________')
print ('%s | %s | %s' %(self.cells[4] , self.cells[5] , self.cells[6]))
print ('_________')
print ('%s | %s | %s' %(self.cells[7] , self.cells[8] , self.cells[9]))
print ('_________')
board = Board()
board.display()
덕분에 많은 도움이되었습니다. –