Answers for "python3 yaml"

4

python write yaml

import yaml

dict_file = [{'sports' : ['soccer', 'football', 'basketball', 'cricket', 'hockey', 'table tennis']},
{'countries' : ['Pakistan', 'USA', 'India', 'China', 'Germany', 'France', 'Spain']}]

with open(r'E:datastore_file.yaml', 'w') as file:
    documents = yaml.dump(dict_file, file)
Posted by: Guest on March-25-2020
0

yaml dump

>>> print yaml.dump({'name': 'Silenthand Olleander', 'race': 'Human',
... 'traits': ['ONE_HAND', 'ONE_EYE']})

name: Silenthand Olleander
race: Human
traits: [ONE_HAND, ONE_EYE]
Posted by: Guest on January-04-2021

Python Answers by Framework

Browse Popular Code Answers by Language