我有一个包含以下行的json文件:
{"param1": 1,
"param2": 250,
"param3": 250}
我在我的python类的init中读到如下:
def __init__(self,filename):
with open(filename) as f:
variables = json.load(f)
for key, value in variables.items():
setattr(self, key, value)
如果我必须读取一个字符串列表的参数,我应该如何修改我的代码和/或json文件? 我的json文件应该是这样的:
{"param1": 1,
"param2": 250,
"param3": 250,
"param4": [true,false,false,true]} <- I am quite sure that this is wrong! :)