您的位置:首页 > 编程语言 > Python开发

python 3.6闭包+循环获取出字典中所有的值并保存在list中

2018-02-22 17:38 513 查看
def list_test():
list1=[]
def list_all_dict(a):
#检测字段类型
if isinstance(a,dict):
for x in range(len(a)):
temp_key=list(a.keys())[x]
temp_value=a[temp_key]

if isinstance(temp_value,dict):
list_all_dict(temp_value)
else:
list1.append(temp_value)
list_all_dict(a)
return list1
if __name__=="__main__":
a={"sex":"eee","name":{"sex":"de","ede":"egg"}}
print(list_test())
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: