Can PyYAML dump dict items in non-alphabetical order?

后端 未结 10 814
一向
一向 2020-11-29 03:38

I\'m using yaml.dump to output a dict. It prints out each item in alphabetical order based on the key.

>>> d = {\"z\":0,\"y\":0,\"x\":         


        
10条回答
  •  暖寄归人
    2020-11-29 04:14

    The following setting makes sure the content is not sorted in the output:

    yaml.sort_base_mapping_type_on_output = False
    

提交回复
热议问题