【发布时间】:2021-07-24 04:57:16
【问题描述】:
我有一个这样的 json 文件:
[
{
"id": "john",
"title": "tech",
"date": "2020/1/1",
"shift": "DAYS"
},
{
"id": "tom",
"title": "tech",
"date": "2021/5/5",
"shift": "NIGHT"
}
]
我需要根据此信息重新创建另一个 JSON 文件。例如:
如果班次 == 晚上:
shiftHourStart = 22:00:00
shiftHourEnd = 06:00:00
所以输出应该是这样的:
[
{
"id": "john",
"title": "tech",
"shiftHourStart" = "22:00:00",
"shiftHourEnd" = "06:00:00"
"shift": "NIGHT"
},
{
"id": "tom",
"title": "tech",
"date": "2021/5/5",
"shiftHourStart" = "06:00:00",
"shiftHourEnd" = "15:00:00",
"shift": "DAY"
}
]
【问题讨论】:
-
到目前为止你尝试过什么?向我们展示您的代码!
-
预期输出与您的描述不符。
-
读取、处理、写入——这些是步骤,您可以单独解决。
标签: python json python-3.x