打印时如何从矩阵中删除科学记数法

How to remove scientific notation from matrix when printed

game_data = '1. e3 e5,2. Qh5 Qf6,3. Qf3 Nc6,4. Qxf6 Nxf6,5. Nf3 d6,6. g3 Nb4,7. Bg2 Nxc2+,8. Kd1 Nxa1,9. b4 Bd7,10. Bb2 Ba4+,11. Kc1 Nc2,12. d4 exd4,13. exd4 d5,14. Nfd2 Bxb4,15. Nf3 Ne4,16. Ba3 Nxa3,17. Nxa3 Bxa3+,18. Kb1 Nc3+,19. Ka1 Bc2,20. Rc1 Bxc1,21. Ne5 Na4,22. Bxd5 Bb2#'
game_data_split = game_data.split(',')
#print(game_data_split)

alphabet = 'abcdefgh'

#below is just a chess board
board = [
    [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.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, 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.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, 0.0, 0.0],
    [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
]

for item in game_data_split:
    #we are going to have to add something to deal with check as a boolean changing every move, or in the middle of every move if white is put in check
    turn,white,black = item.split()
    if white == 'O-O-O':
        x = [0,1,2]
        y = 0
        board[x][y] += 0.1
    if white.endswith('+'):
        x = alphabet.index(white[-3])
        y = int(white[-2]) -1
        board[y][x] += 0.01
    elif white.endswith('#'):
        x = alphabet.index(white[-3])
        y = int(white[-2]) -1
        board[y][x] += 0.001
    else:
        x = alphabet.index(white[-2])
        y = int(white[-1]) - 1
    board[y][x] += 0.00001
    if black == 'O-O-O':
        x = [5,6,7]
        y = [7]
        board[y][x] += 1
    if black.endswith('+'):
        x = alphabet.index(black[-3])
        y = int(black[-2]) -1
        board[y][x] += 10
    elif black.endswith('#'):
        x = alphabet.index(black[-3])
        y = int(black[-2]) -1
        board[y][x] += 100
    else:
        x = alphabet.index(black[-2])
        y = int(black[-1]) - 1
    board[y][x] +=1000
    print(turn)
    pprint(board)

我正在构建一个棋盘可视化工具来学习,我的结果似乎正确,但我不断得到像 1e-05 甚至 3.0000000000000004e-05 这样的结果。我真的不想在我的结果中使用这种科学记数法。如何让印制板停止显示科学计数法?

我在 this link 中找到了答案。

只需将以下代码行放入您的程序中:

np.set_printoptions(suppress=True)

在该行之后打印的任何矩阵都将隐藏科学记数法。