Python正在打印Json字符串,格式是\n和unicode?

2024-09-30 01:22:06 发布

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

嗨伙计们这是我的内容.json文件

[{"content": "Let\u2019s go home \n\u00a0\nNow", "channel_id": "423266223960096770", "mentions": [], "type": 0}]

这是我的代码.py你知道吗

with open('content.json', 'r') as current_stuff:
    before = json.loads(current_stuff.read())       

before_set = []
for b in before:
    before_set.append(b['content']) 

setx = str(before_set) 
string9 = str(''.join( c for c in setx if c not in "[{'}]" ))   

print (string9)

打印输出:

Let’s go home \n\xa0\nNow

我要像这样打印出来

Let’s go home

Now

当我这么做的时候:

print ("Let\u2019s go home \n\u00a0\nNow")

我怎样才能解决这个问题?你知道吗


Tags: injsongohomeforcontentcurrentlet

热门问题