Python reddit praw刮除表情符号和whwat编码使用

Python reddit praw刮除表情符号和whwat编码使用,python,encoding,reddit,praw,Python,Encoding,Reddit,Praw,嘿,伙计们,我有一个文本文件,我使用reddit praw从reddit中刮取: Is that intended or a bug? WHAT. I’m on the way to my pubs. Does first hit desolator remove ti shuffle thread? 🤔🤔 My brother works at valve and I confirm this 所以我想知道为什么当我将字符串保存到txt时,我会得到如下结果: with

嘿,伙计们,我有一个文本文件,我使用reddit praw从reddit中刮取:

Is that intended or a bug? WHAT. I’m on the way to my pubs.
Does first hit desolator remove ti shuffle thread? 🤔🤔 My brother works at valve and I confirm this
所以我想知道为什么当我将字符串保存到txt时,我会得到如下结果:

    with open(str(number)+".txt",'w', newline='',encoding="utf-8") as out:
        out.write(toPrint)
        out.close()

我不确定我是否使用了错误的unicode,是否有任何方法可以消除这些噪音?我确信第一个是我,第二个是reddit的表情符号,我更喜欢删除表情符号,因为这样做似乎更简单。

toPrint.encode('ascii','ignore').decode()
谢谢回复,所以在写入txt之前先这样做?是的,或者你可以像
out.write(toPrint.encode('ascii','ignore')).decode())
这就完成了工作,谢谢!太棒了:)