使用json.dumps 将 json 格式的数据写到文件里
import json with open('measurements.json', 'w') as f: f.write(json.dumps(measurements))