小编mss*_*nse的帖子

Python:如何在不使用双引号的情况下修复JSON键值?

我目前有以下格式的JSON。一些键值的格式不正确,因为它们缺少双引号(“)

如何修复这些键值以使其带有双引号?

    {      
Name: "test",
Address: "xyz",
"Age": 40,
"Info": "test"
}
Run Code Online (Sandbox Code Playgroud)

需要:

    {      
"Name": "test",
"Address": "xyz",
"Age": 40,
"Info": "test"
}
Run Code Online (Sandbox Code Playgroud)

使用下面的文章,我能够在上面的INVALID JSON中找到这样的键值。但是,我找不到用双引号替换这些找到的值的有效方法。

s = "Example: String"
out = re.findall(r'\w+:', s)
Run Code Online (Sandbox Code Playgroud)

如何在JSON中转义双引号

python regex json

2
推荐指数
4
解决办法
1385
查看次数

标签 统计

json ×1

python ×1

regex ×1