小编ana*_*cky的帖子

如何发送一个漂亮的json对象作为电子邮件python

我有一个 python 脚本,它以 json 形式获取集群运行状况并向我发送邮件。问题是 json 没有很好地打印出来。这些是我已经尝试过的方法:

  1. 简单 --> json.dumps(health)
  2. json.dumps(health, indent=4, sort_keys=True)

但是gmail中的输出还是没有格式化的,有点像这样

{ "active_primary_shards": 25, "active_shards": 50, "active_shards_percent_as_number": 100.0, "cluster_name": "number_of_pending_tasks": 0, "relocating_shards": 0, "status": "green", "task_max_waiting_in_queue_millis": 0, "timed_out": false, "unassigned_shards": 0 }

邮件已发送至 gmail

python email json elasticsearch

3
推荐指数
1
解决办法
4474
查看次数

标签 统计

elasticsearch ×1

email ×1

json ×1

python ×1