diff --git a/main.py b/main.py index e29df16d6af41149660cf9e7918bf08bd45ef34f..1517b70126e5eb5831a47ee66044411994fb63c5 100644 --- a/main.py +++ b/main.py @@ -1,5 +1,6 @@ import random import time + def draw_dot(level): print(' ', end=' ') for i in range(level): @@ -128,6 +129,7 @@ while True: board = new_board(level) mines = lay_mines(level, level) draw_board(board,level) + start_time = time.time() while True: move = is_valid_move(input('请选择位置:'), level) if not move: continue @@ -136,4 +138,8 @@ while True: dig_mine(row, column, mines, level) if is_win(board, mines, level) or is_lose(board, mines, level): break draw_board(board,level) - if not play_again(): break \ No newline at end of file + end_time = time.time() + print(f"用时:{end_time-start_time:.2f}秒") + if not play_again(): + print("下次再见!") + break \ No newline at end of file