小编Meh*_*ifi的帖子

从字符串中提取字典

我正在调用一个返回包含字典的字符串的函数。我怎样才能提取这个字典,记住第一行和最后一行可能包含“{”和“}”。

This is a {testing string} example
This {is} a testing {string} example
{"website": "stackoverflow",
"type": "question",
"date": "10-09-2020"
}
This is a {testing string} example
This {is} a testing {string} example
Run Code Online (Sandbox Code Playgroud)

我需要将此值提取为字典变量。

{"website": "stackoverflow",
"type": "question",
"date": "10-09-2020"
}
Run Code Online (Sandbox Code Playgroud)

python string dictionary

5
推荐指数
1
解决办法
1392
查看次数

标签 统计

dictionary ×1

python ×1

string ×1