if your .yml. file looks somewhat like this:
- server:
var:
server_name: ml-apitest-t1
then you should use PyYaml, try this
import yaml
try:
from yaml import CLoader as Loader, CDumper as Dumper
except ImportError:
from yaml import Loader, Dumper
with open('test.yml', 'r') as f:
cont = yaml.load(f.read(), Loader=Loader)
print (cont)
in the case of my example it would output this
[{'server': {'var': None, 'server_name': 'ml-apitest-t1'}}]
to get the server_name from my test .yml file i would need to do this, but i your case it would look different because your .yml file structure is different
import yaml
try:
from yaml import CLoader as Loader, CDumper as Dumper
except ImportError:
from yaml import Loader, Dumper
with open('test.yml', 'r') as f:
cont = yaml.load(f.read(), Loader=Loader)
print (cont[0]['server']['server_name'])
and this is the output
ml-apitest-t1
Also here is the PyYaml documentation