私はかなり長い間同じ戦艦ゲームに取り組んでおり、最終段階に近づいています。次に、関数 を使用して、上位 5 つのスコアをテキスト ファイルに保存する必要がありますdef saveScore
。try
次に、作成したばかりのファイルを読み取り、 and except
for file open and closeを使用してスコアを Python コードにロードする必要があります。Python に変数を認識させる方法がわかりません。変数score
はローカルにしかないと信じているからです。これが私が持っているものです。ピクルスの使い方がわかりません。
def main():
board=createBoard()
printBoard(board)
s = [[21,22,23,24,25],
[45,55,65,75],
[1,2,3],
[85,86,87],
[5,15],
[46,56]]
playBattleship(s,board)
main()