Тема: конвертування стрічки в dictionary
Так працює ок:
var1 = {"a":"1","2":{"1","2","3","4","5","6","7","8"}}
print(var1)
а так повертає помилку:
import json
var1 = '{"a":"1","2":{"1","2","3","4","5","6","7","8"}}'
querystring = json.loads(var1)
print(querystring)
---------------------------------------------------------------------------
JSONDecodeError Traceback (most recent call last)
<ipython-input-18-9b701aff7ad9> in <module>
2
3 var1 = '{"a":"1","2":{"1","2","3","4","5","6","7","8"}}'
----> 4 querystring = json.loads(var1)
5 print(querystring)~/anaconda3/lib/python3.8/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~/anaconda3/lib/python3.8/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):~/anaconda3/lib/python3.8/json/decoder.py in raw_decode(self, s, idx)
351 """
352 try:
--> 353 obj, end = self.scan_once(s, idx)
354 except StopIteration as err:
355 raise JSONDecodeError("Expecting value", s, err.value) from NoneJSONDecodeError: Expecting ':' delimiter: line 1 column 18 (char 17)
Підкажіть як виправити...