python - 用于文件节拍的 json EOL
问题描述
通过python脚本从api中转储一些json数据,并保存到文件中,需要将这些数据推送到elasticsearch。Filebeat 需要 EOL 来解析 json 数据。
我们如何通过python将EOL添加到json?
保存文件使用 json.dump
with open('/tmp/file.log', 'w') as f:
json.dump(incident, f)
解决方案
推荐阅读
- python-2.7 - 如何通过 Python 使用 Selenium 从元素中获取文本
- python - 将字典转换为(密集)矩阵的快速方法
- python - AttributeError:模块'networkx'没有属性'Graph'--duplicate
- sapui5 - 查找设备 ID - SAP UI5
- iso - ISO8583 - 如何生成和分配 STAN 11 字段?
- visual-studio-mac - Visual Studio 2019 for Mac 上的键绑定丢失
- python-3.x - 如何连接两个不同长度的列表来填充缺失值
- reactjs - 是否有任何 linter 可以检测文件扩展名 .tsx/.jsx 何时不包含任何 JSX,因此可以是 .ts/.js
- hadoop - 将 S3 用于 HIVE 元存储?
- javascript - 如何将 AWS 中 kinesisvideomedia.getMedia 请求中的 data.Payload 转换/解码为 mkv 文件?