From 8ea9ed5a4d13c940fa8babca101e80ac7519568e Mon Sep 17 00:00:00 2001 From: Silver Kuusik Date: Sat, 13 Jan 2018 16:13:49 +0100 Subject: [PATCH] update better way to read file --- boot.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/boot.py b/boot.py index 92b730b..6eed3af 100644 --- a/boot.py +++ b/boot.py @@ -6,8 +6,10 @@ from time import sleep print("Press Ctrl-C to stop boot script...") sleep(0.2) -# read the config file -config = ujson.loads(open("config.json", "r").read()) +# open and parse the config file +config = None +with open("config.json", "r") as config_file: + config = ujson.load(config_file) # connect to WiFi wlan = network.WLAN(network.STA_IF)