import yaml
import pprint
with open(r'learnyaml.yaml') as file:
# The FullLoader parameter handles the conversion from YAML
# scalar values to Python the dictionary format
yaml2 = yaml.load(file, Loader=yaml.FullLoader)
pprint.sorted = lambda x, key=None: x # disable sort in pprint
pp.pprint(yaml2) # this can pretty print the dict, but the output is unordered
print()
how to disable sort in pprint in python
最新推荐文章于 2021-11-18 17:03:09 发布