Search code examples
pythonyamlprometheusetcd

Load Yaml file in Python without converting to dict


I need to store the content of a yaml file to a variable as it is(without converting to dictionary) or after storing it as dictionary is there any way to bring back to yaml format without storing it inside the file. I tried with yaml.load(file) which returns the object in dictionary. Is there any way to achieve?


Solution

  • What about?

    ymlFile = open('file.yml').read()

    https://www.pythonforbeginners.com/files/reading-and-writing-files-in-python