python - How do I write a YAML file using a dictionary with long keys and values? -
i have python dictionary has 25-30 key-value pairs. keys long strings (20-30 characters), , values can 1-10 lines long embedded new-lines, etc.
i write file using yaml, if use yaml.dump not readable, because of length of data. file following example:
this_is_my_very_long_key_1 : "this value key 1" this_is_a_shorter_key : "this value key" i finding yaml documentation sparse.
i tried using default_flow_style=false or true, , looked better no-flow, that's not wanted.
you can limit width of line passing width parameter dump method.
yaml.dump(d, width=20, default_flow_style=false)
Comments
Post a Comment