Python中字符串与字典互相转换

Python中字符串与字典互相转换

1.str转字典

方法1

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

方法2

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

2.字典转str

可以直接 使用 str()转换

b=str(c)

猜你喜欢

转载自blog.csdn.net/weixin_49092628/article/details/113101480