本站改版新增arduino频道
import os def save(key, value): filename = '/' + key + '.json' f = open(filename, 'w') json_str = json.dumps(value) f.write(json_str) f.close() def load(key, default = None): filename = '/' + key + '.json' try: f = open(filename) json_str = f.read() value = json.loads(json_str) f.close() return value except: if default == None: raise ValueError() return default save("key1", "123") save("key2", "456") print(load("key1")) print(load("key2"))
Copyright © 2014 ESP56.com All Rights Reserved
晋ICP备14006235号-22 晋公网安备14108102001165号
执行时间: 0.0092740058898926 seconds