美文网首页
python 处理json,list to dict

python 处理json,list to dict

作者: peiyang | 来源:发表于2018-03-12 17:40 被阅读0次

    #处理json字符串

    def replace_json_value_bykey(data):

    if data==np.nan

    return np.nan

    else:

    import json

    #读取成字典类型数据

    data_json=json.loads(data)

    dict=[]

    def json_txt(dict_json):

    if isinstance(dict_json,dict):

    for key in dict_json:

    if isinstance(dict_json[key],dict)

    json_txt(dict_json[key])

    dict[key]=dict_json[key]

    else:

    dict[key]=dict_json[key]

    def replace_json_value(dict_json,k,v):

    if isinstance(dict_json,dict):

    for key in dict_json:

    if key==k:

    dict_json[key]=v

    elif isinstance(dict_json[key],dict):

    replace_json_value(dict_json[key],dict)

    for temp_data in data_json:

    replace_json_value(temp_data,'payAcct','*****')

    return data_json

    相关文章

      网友评论

          本文标题:python 处理json,list to dict

          本文链接:https://www.haomeiwen.com/subject/gdcofftx.html