python 处理json,list to dict

#处理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_第1张图片

你可能感兴趣的:(python 处理json,list to dict)