I
loads
можно свою функцию обработки подложить
Size: a a a
I
loads
s
I
s
I
s
EM
"'"
. Сделав замену '
на "
получу сами понимаете что...PB
I
PB
I
re.sub(r'\'(.*?)\'', r'"\1"', "'test' ''' \"'\"")
"'"
заменяет на """
? 😒ОК
Json
, в котором используются одинарные кавычки и True/False
без кавычек вообще. json.loads()
такое не кушает. Есть способ красиво декодировать?S
re.sub(r'\'(.*?)\'', r'"\1"', "'test' ''' \"'\"")
"'"
заменяет на """
? 😒Some people, when confronted with a problem, think
“I know, I'll use regular expressions.” Now they have two problems.
S
S
py3
import ast
not_json = '''
{'hello': 'world'}
'''
dict_ = ast.literal_eval(not_json)
print(dict_, type(dict_))
print('The value of "hello" is "{}"'.format(dict_['hello']))
{'hello': 'world'} <class 'dict'>
The value of "hello" is "world"
I
I
I
AI