我在Python脚本中替换换行符提要和回车时遇到了一些问题,我尝试了很多方法,但都没有成功。我尝试了StackOverflow的不同解决方案,但似乎没有任何效果
输入的JSON文件示例:
"isActive" : true,
"Level" : 4,
"actions" : [
{
"isActive" : true,
"description" : "Alert escalation for handover delays. \r\n"
},
{
"isActive" : true,
"description" : "Notify Director \r\n"
}
我现在就是这样做的:
from pymongo import MongoClient
import pandas as pd
from azure.storage.filedatalake import DataLakeServiceClient
from azure.core._match_conditions import MatchConditions
from azure.storage.filedatalake._models import ContentSettings
from pandas import json_normalize
from datetime import datetime, timedelta
mongo_client = MongoClient("XXXX")
db = mongo_client.scale_db
table = db.scaling
document = table.find()
docs = list(document)
docs = json_normalize(docs)
docs.replace(r"\n",'').replace(r"\r",'').replace(r"\r\n",'')
然而,我仍然看到它们在某些范围内:
17,False,1029,[6104],6,"[{'isActive': True, 'pressureLevel': 2, 'actions': [{'isActive': True, 'description': 'Team manager to review caseload during Wash up and with site matrons\r\n'}
我是做错了什么还是错过了什么
提前谢谢
记住捕获输出
相关问题 更多 >
编程相关推荐