import json
my_mapping = {'a': 23, 'b': 42, 'c': 0xc0ffee}
print(json.dumps(my_mapping, indent=4, sort_keys=True))

通过设置dumps的indent参数,能够实现pprint打印的效果。让结构格式更加好看。

相关文章:

  • 2021-09-27
  • 2021-11-21
  • 2022-02-13
  • 2022-12-23
  • 2021-05-21
  • 2022-12-23
  • 2021-09-19
  • 2022-12-23
猜你喜欢
  • 2021-05-21
  • 2022-12-23
  • 2022-12-23
  • 2021-06-06
  • 2021-08-20
  • 2021-11-30
  • 2022-12-23
相关资源
相似解决方案