代码取自GitHub:https://github.com/microsoft/AutonomousDrivingCookbook
在进行Step 0 - Set up the Cluster中,需要读取notebook_config.json文件,解码器报错
with open('F:/AutonomousDrivingCookbook-master/DistributedRL/notebook_config.json','r') as f:
NOTEBOOK_CONFIG = json.loads(f.read())
---------------------------------------------------------------------------
JSONDecodeError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_19040/4186426040.py in <module>
23
24 with open('F:/AutonomousDrivingCookbook-master/DistributedRL/notebook_config.json','r') as f:
---> 25 NOTEBOOK_CONFIG = json.loads(f.read())
D:\Python\anaconda\anaconda3\lib\json\__init__.py in loads(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
355 parse_int is None and parse_float is None and
356 parse_constant is None and object_pairs_hook is None and not kw):
--> 357 return _default_decoder.decode(s)
358 if cls is None:
359 cls = JSONDecoder
D:\Python\anaconda\anaconda3\lib\json\decoder.py in decode(self, s, _w)
335
336 """
--> 337 obj, end = self.raw_decode(s, idx=_w(s, 0).end())
338 end = _w(s, end).end()
339 if end != len(s):
D:\Python\anaconda\anaconda3\lib\json\decoder.py in raw_decode(self, s, idx)
353 obj, end = self.scan_once(s, idx)
354 except StopIteration as err:
--> 355 raise JSONDecodeError("Expecting value", s, err.value) from None
356 return obj, end
JSONDecodeError: Expecting value: line 14 column 1 (char 354)
notebook_config.json文件中最后一个属性"batch_pool_size":之后没有值
改成
"batch_pool_size":""
{
"subscription_id": "",
"resource_group_name": "",
"storage_account_name": "",
"storage_account_key": "",
"file_share_name": "",
"batch_account_name": "",
"batch_account_key": "",
"batch_account_url": "",
"batch_job_user_name": "",
"batch_job_user_password": "",
"batch_pool_name": "",
"batch_pool_size": ""
}
如有帮助,请点击我的回答下方的【采纳该答案】按钮帮忙采纳下,谢谢!
是json.load,json.loads是将json字符串转换为字典,读取文件的是json.load,参数不用写read啦
下面这样
with open("model.json",'r') as load_f:
load_dict = json.load(load_f)
有帮助的话采纳一下哦🙈🙈🙈