这是定义移动编号的代码
def move(pos,empty,board):
m = pos[0]//
n = pos[1]
if empty == (m-1,n) or empty == (m+1,n)or empty == (m,n-1) or empty == (m,n+1):
board[empty[0]][empty[1]] = num
board[m][n] = 0
empty = (m,n)
else :
print('can\'t move! try again.')
结果是:
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
sliding_puzzle()
File "C:\Users\sungod\Desktop\과제.py", line 57, in sliding_puzzle
(empty,board)=move(pos,empty,board)
File "C:\Users\sungod\Desktop\과제.py", line 35, in move
m = pos[0]
TypeError: 'NoneType' object is not subscriptable
如果对象不可下标,则它不具有以下任何形式:
也就是说pos不是这些。我从你提供的资料中猜到的。。你知道吗
相关问题 更多 >
编程相关推荐