0

数据如下

{
    "message":"abc","result":{
            "paramtypeitems":[
                {"name":"基本参数","paramitems":[
                    {"id":567,"name":"车型","valueitems":[
                        {"specid":37017,"value":"xDrive40i M运动套装"},
                        {"specid":37018,"value":"xDrive40i 尊享型 M运动套装"},
                        {"specid":33307,"value":"xDrive28i"}]
                    }]
                }]
            }
        }
ilovelnmp 284
2019-01-18 提问
1 个回答
1

已采纳

json和pandas配合下

import json
import pandas as pd
js='''
{
    "message":"abc","result":{
            "paramtypeitems":[
                {"name":"基本参数","paramitems":[
                    {"id":567,"name":"车型","valueitems":[
                        {"specid":37017,"value":"xDrive40i M运动套装"},
                        {"specid":37018,"value":"xDrive40i 尊享型 M运动套装"},
                        {"specid":33307,"value":"xDrive28i"}]
                    }]
                }]
            }
        }
'''
dj=json.loads(js)
d=dj['result']['paramtypeitems'][0]['paramitems'][0]['valueitems']
df=pd.DataFrame(d)
print(df)

撰写答案

推广链接