Python yaml

From wikinotes
Revision as of 02:13, 18 May 2023 by Will (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


read

with open(filepath, 'r') as stream:
 	my_dict = yaml.safe_load(stream)


write

with open(filepath, 'w') as fd:
    fd.write( 
        yaml.safe_dump(dictionary, default_flow_style=False)
    )