【问题标题】:Format JSON to one line per input将 JSON 格式化为每个输入一行
【发布时间】:2019-10-23 13:13:46
【问题描述】:

我正在尝试使我的 json 与 Google ML 兼容,经过一番搜索后,这意味着每个输入实例只有一行 (Input instances are not in JSON format.)

如何将我的代码更改为每个实例只有一行? (img变量是我编码成base64的图片)

json.dumps({"inputs": {"b64": img}})

【问题讨论】:

标签: python json python-3.x google-cloud-platform


【解决方案1】:

您所指的格式称为 json-lines(.jl 表示文件扩展名)。
您可以使用json-lines python 包代替json.dumps

【讨论】:

    猜你喜欢
    • 2014-10-17
    • 1970-01-01
    • 2013-03-22
    • 1970-01-01
    • 2019-12-16
    • 1970-01-01
    • 2020-08-21
    • 2016-07-23
    • 2021-10-16
    相关资源
    最近更新 更多