“Python schreibe Yaml” Code-Antworten

Python las Yaml

# read_categories.py file

import yaml

with open(r'E:\data\categories.yaml') as file:
    documents = yaml.full_load(file)

    for item, doc in documents.items():
        print(item, ":", doc)
Stupid Stork

Python schreibe 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:\data\store_file.yaml', 'w') as file:
    documents = yaml.dump(dict_file, file)
Stupid Stork

Ähnliche Antworten wie “Python schreibe Yaml”

Fragen ähnlich wie “Python schreibe Yaml”

Weitere verwandte Antworten zu “Python schreibe Yaml” auf Python

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen