简体   繁体   中英

How to get a string of the FEN position

After I do

import chess
board = chess.Board()

how can I have a string with the FEN of the position? In other words, how can I extract from board the FEN of the position as a string, with the same output as if I did

a='rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1'

?

You can use the fen function.

board = chess.Board()
a = board.fen()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM