pip install pyyaml
# foo.yaml foo: bar pleh: help stuff: foo: bar bar: foo
import yaml with open('foo.yaml') as file: content = yaml.load(file, Loader=yaml.FullLoader) print(content)
import yaml dictionary = {'Name': 'Lin', 'Age': 41, 'Children': ['Hannah', 'Hadley'], 'Lobbies': {'Swim':'Normal', 'Running':'Professional'}} with open('temp.yaml', 'w') as file: yaml.dump(dictionary, file)
# temp.yaml Age: 41 Children: - Hannah - Hadley Lobbies: Running: Professional Swim: Normal Name: Lin