从JSON中删除特殊字符

2024-03-29 07:49:39 发布

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

我有一个JSON文件,有一个类似于3的对象:

[{"ID": "44585", "TITLE": "A day in *Australia*=/", "MailThread": [{"email": " Its a great day, isn't it."}, {"email": " Yes, indeed."}, {"email": " Great Day!!!"}], "SUMMARY": "", "NAME": "Mike's Journal", "PRIORITY": 3, "FLIGHTTICKETNO": 25565826, "CODENAME": "ausTrip", "DESC": "I am really feeling great*&^% to be here!! I love this place, and find it's places amazin#@$. Thanks!!"},{"ID": "44585", "TITLE": "A day in *Australia*=/", "MailThread": [{"email": " Its a great day, isn't it."}, {"email": " Yes, indeed."}, {"email": " Great Day!!!"}], "SUMMARY": "", "NAME": "Mike's Journal", "PRIORITY": 3, "FLIGHTTICKETNO": 25565826, "CODENAME": "ausTrip", "DESC": "I am really feeling great*&^% to be here!! I love this place, and find it's places amazin#@$. Thanks!!"},{"ID": "44585", "TITLE": "A day in *Australia*=/", "MailThread": [{"email": " Its a great day, isn't it."}, {"email": " Yes, indeed."}, {"email": " Great Day!!!"}], "SUMMARY": "", "NAME": "Mike's Journal", "PRIORITY": 3, "FLIGHTTICKETNO": 25565826, "CODENAME": "ausTrip", "DESC": "I am really feeling great*&^% to be here!! I love this place, and find it's places amazin#@$. Thanks!!"}]

我需要删除标题中的特殊字符,如*=/,&;^#@,所有3个对象的MailThread和DESC中的多封电子邮件,并将编辑后的内容写入一个新的json文件。在


Tags: inidtitleemailitdescyesits
1条回答
网友
1楼 · 发布于 2024-03-29 07:49:39

只处理标题,如果您需要其他东西,请自己按如下方式处理:

$ python demo.py
{'PRIORITY': 3, 'TITLE': 'A day in Australia', 'FLIGHTTICKETNO': 25565826, 'MailThread': [{'email': " Its a great day, isn't it."}, {'email': ' Yes, indeed.'}, {'email': ' Great Day!!!'}], 'CODENAME': 'ausTrip', 'SUMMARY': '', 'NAME': "Mike's Journal", 'ID': '44585', 'DESC': "I am really feeling great*&^% to be here!! I love this place, and find it's places amazin#@$. Thanks!!"}
{'PRIORITY': 3, 'TITLE': 'A day in Australia', 'FLIGHTTICKETNO': 25565826, 'MailThread': [{'email': " Its a great day, isn't it."}, {'email': ' Yes, indeed.'}, {'email': ' Great Day!!!'}], 'CODENAME': 'ausTrip', 'SUMMARY': '', 'NAME': "Mike's Journal", 'ID': '44585', 'DESC': "I am really feeling great*&^% to be here!! I love this place, and find it's places amazin#@$. Thanks!!"}
{'PRIORITY': 3, 'TITLE': 'A day in Australia', 'FLIGHTTICKETNO': 25565826, 'MailThread': [{'email': " Its a great day, isn't it."}, {'email': ' Yes, indeed.'}, {'email': ' Great Day!!!'}], 'CODENAME': 'ausTrip', 'SUMMARY': '', 'NAME': "Mike's Journal", 'ID': '44585', 'DESC': "I am really feeling great*&^% to be here!! I love this place, and find it's places amazin#@$. Thanks!!"}

代码

^{pr2}$

相关问题 更多 >