Conversion between strings and dictionaries in Python

Conversion between strings and dictionaries in Python

1.str to dictionary

method 1

a = '{"a":"1", "b":"1"}'
b = evel(a)

Method 2

import json
a = '{"a":"1", "b":"1"}'
c=json.loads(a)

2. Convert dictionary to str

You can use str() directly to convert

b=str(c)

Guess you like

Origin blog.csdn.net/weixin_49092628/article/details/113101480