How to determine the encoding of text?

前端 未结 10 1475
一向
一向 2020-11-21 07:47

I received some text that is encoded, but I don\'t know what charset was used. Is there a way to determine the encoding of a text file using Python? How can I detect the enc

10条回答
  •  不知归路
    2020-11-21 08:13

    It is, in principle, impossible to determine the encoding of a text file, in the general case. So no, there is no standard Python library to do that for you.

    If you have more specific knowledge about the text file (e.g. that it is XML), there might be library functions.

提交回复
热议问题