在邮递员项目中,我在单个环境 JSON 文件中维护多个变量。
为了维护代码,我想从 JSON 文件中获取特定的对象,这意味着所需的对象并写入新的 JSON 文件。(例如从附图中),想要获取键名称为“UTCDateTime”的对象并将其写入到一个单独的 JSON 文件中。
JS可以吗? 预先感谢
此代码位于 python 3 中:
with open('[The file name you are reading]', 'r') as f:
data = json.load(f)
with open('[The file name you are writing to]', 'w') as r:
loaded = json.dumps(f, r, indent=2)```