依赖
rpm -qa | grep PyYAML
PyYAML-3.10-3.1.el6.x86_64
例子代码
#!/usr/bin/python
import os, sys,yaml
fname="index.yaml"
f = open(fname,"r")
x=yaml.load(f)
#print(x)
dist={}
dlist="centos6.x86_64|centos7.x86_64"
arr = dlist.split("|")
for ite in arr:
dist[ite] = {}
dist[ite]['release'] = "{{.gitcount}}.{{.dist}}"
x['distribution'] = dist
#print "\n\n"
#print x
#print "\n"
ret = yaml.dump(x)
print ret
2 Comments