标签:yam hand bsp pen desktop name load print open
yaml文件的读取与保存
# 读取yaml文件
with open(‘C:\\Users\\51102\\Desktop\\123\\info.yaml‘) as f:
temp = yaml.load(f.read(), Loader=yaml.FullLoader)
labels = temp[‘label_names‘]
del labels[0] # 删除列表第一个元素
print(labels)
# 建立一个yaml文件
with open(‘C:\\Users\\51102\\Desktop\\123\\iddnfo.yaml‘,‘w‘) as ff:
aproject = {‘name‘: ‘Silenthand Olleander‘,
‘race‘: ‘Human‘,
‘traits‘: [‘ONE_HAND‘, ‘ONE_EYE‘]
}
yaml.dump(aproject,ff)
ff.close()
标签:yam hand bsp pen desktop name load print open
原文地址:https://www.cnblogs.com/tangjunjun/p/12210725.html