📜  python 编写 yaml - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:21.648000             🧑  作者: Mango

代码示例2
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)