From 7527fca972b2d69318fc2471fad9904efe9946f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=9F=E5=A4=96=E4=B9=8B=E7=A5=9E?= Date: Fri, 17 Jun 2022 11:45:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=89=E5=85=A8=E6=89=93=E5=BC=80=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/state/level.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/source/state/level.py b/source/state/level.py index febdad2..4d85381 100644 --- a/source/state/level.py +++ b/source/state/level.py @@ -45,9 +45,8 @@ class Level(tool.State): file_path = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))),'resources' , 'data', 'map', map_file) # 最后一关之后应该结束了 try: - f = open(file_path) - self.map_data = json.load(f) - f.close() + with open(file_path) as f: + self.map_data = json.load(f) except: print("成功通关!") if self.game_info[c.GAME_MODE] == c.MODE_LITTLEGAME: