내가 다른리스트에 목록을 추가하려면 '추가', 그러나 그것은 나에게 오류 제공 : 목록에 목록을 추가 : AttributeError는 'NoneType'개체가 어떤 속성이 없습니다
AttributeError: 'NoneType' object has no attribute 'append'
원래 내가 원했던를
여기 내 코드의 ... 배열에 목록을 추가,하지만 또한 작동하지 않았다 :
import numpy
board = numpy.array([[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 1, 2, 0, 0, 0],
[0, 0, 0, 2, 1, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0]])
class AI:
def __init__(self, board):
self.board = board
def flank_search(self):
free = []
xcoord = 0
ycoord = 0
while 0 <= xcoord and xcoord <= 7 and 0 <= ycoord and ycoord <= 7:
if self.board[xcoord][ycoord] == 0:
coord1 = [xcoord, ycoord]
free = free.append([coord1])
xcoord += 1
print free
return free
flank = AI(board)
flank.flank_search()
이것은 구현상의 문제이므로 SO로 마이그레이션해야합니다. 중재자 중 한 명은 중복 질문을 방지하기 위해이를 수행 할 수 있습니다. –
@AdamZuckerman : 중복으로 닫힐 것입니다. –