我从网页获取一个 PHP 数组(作为字符串)。 看起来像:
Array
(
[k1] => Array
(
[a] => Array
(
[id] => 1
[age] => 60
)
[b] => Array
(
[id] => 2
[age] => 30
)
)
[k2] => v2
)
我想用 python 解析它。 有谁知道如何做到这一点?
谢谢, 里夫卡
编辑: 这真的不是 json,就像一些人评论的那样。 感谢您的评论,我更新了问题。
最佳答案
那不是 JSON,那只是 PHP 打印数组的方式。如果要创建数组的 JSON,请查看 json_encode对于 PHP。然后使用 Python's JSON library (或此处为 py3)阅读。
关于php - 在python中解析php数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6174031/