Python yaml

From wikinotes
Revision as of 19:39, 26 June 2017 by Will (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


read

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


write

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