Delete every non utf-8 symbols from string

前端 未结 4 1201
故里飘歌
故里飘歌 2020-11-29 05:46

I have a big amount of files and parser. What I Have to do is strip all non utf-8 symbols and put data in mongodb. Currently I have code like this.

with op         


        
4条回答
  •  春和景丽
    2020-11-29 06:11

    Try below code line instead of last two lines. Hope it helps:

    line=line.decode('utf-8','ignore').encode("utf-8")
    

提交回复
热议问题