写在前面:因为想使用 json.loads 函数将字符型(str)转为json的格式, 但这个函数要求str必须是标准的json的代码格式,我想转换的str 不是标准的, 文中含有多余 的 双引号 " 所以导致转换失败 如图1

做法: 先把 双引号替换为特殊字符,然后根据json 的 格式再次进行替换
图二 贴代码

亲测有效哦~
写在前面:因为想使用 json.loads 函数将字符型(str)转为json的格式, 但这个函数要求str必须是标准的json的代码格式,我想转换的str 不是标准的, 文中含有多余 的 双引号 " 所以导致转换失败 如图1
做法: 先把 双引号替换为特殊字符,然后根据json 的 格式再次进行替换
图二 贴代码
亲测有效哦~
本文标题:Python 关于str 转 json 中多余引号
本文链接:https://www.haomeiwen.com/subject/gojgwctx.html
网友评论