import yaml
with open('aa.yaml', "r") as file:
data = yaml.load(file, Loader = yaml.FullLoader)
def yaml_flat(x):
for key, value in x.items():
if isinstance(value, dict):
for k, v in yaml_flat(value):
k = f'{key}.{k}'
yield (k, v)
else:
yield (key, value)
aa = yaml_flat(data)
for k,v in aa:
print("kkk=",k, 'vvvv=',v)
标签:aa,flat,file,路径,value,yaml,key
From: https://www.cnblogs.com/wl30564/p/17310039.html