删除换行符

2024-06-09 18:46:14 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在从firebase下载数据,并将其导出为json。在这之后,我试图将其上传到bigquery中,但是我需要删除bigquery的新行提要才能接受它。在

这就是我从firebase收到的。在

{
"ConnectionTime": 730669.644775033, 
"objectId": "eHFvTUNqTR", 
"CustomName": "Relay Controller", 
"FirmwareRevision": "FW V1.96", 
"DeviceID": "F1E4746E-DCEC-495B-AC75-1DFD66527561", 
"PeripheralType": 9, 
"updatedAt": "2016-12-13T15:50:41.626Z", 
"Model": "DF Bluno", 
"HardwareRevision": "HW V1.7", 
"Serial": "0123456789", 
"createdAt": "2016-12-13T15:50:41.626Z", 
"Manufacturer": "DFRobot"}
{
"ConnectionTime": 702937.7616419792, 
"objectId": "uYuT3zgyez", 
"CustomName": "Relay Controller", 
"FirmwareRevision": "FW V1.96", 
"DeviceID": "F1E4746E-DCEC-495B-AC75-1DFD66527561", 
"PeripheralType": 9, 
"updatedAt": "2016-12-13T08:08:29.829Z", 
"Model": "DF Bluno", 
"HardwareRevision": "HW V1.7", 
"Serial": "0123456789", 
"createdAt": "2016-12-13T08:08:29.829Z", 
"Manufacturer": "DFRobot"}

这就是我需要它的方式,但是除了手动操作之外,我不知道该怎么做。在

^{pr2}$

我正在使用python加载json,读取它,然后编写一个新的json,但无法找到正确的代码。谢谢您!在

下面是我的python代码的大纲

import json
with open('nospacetest.json', 'r') as f:
  data_json=json.load(f)

#b= to file afte code for no line breaks is added

with open('testnoline.json', 'w') as outfile:
  json.dump=(b, outfile)

Tags: jsonbigqueryrelayobjectidcontrollerfirebasefwdeviceid