When using Python, you often encounter the problem of encoding and decoding text, which is a common decoding error as shown in the topic, the following describes the error resolution, the ' GBK ' to ' utf-8 ' also applicable.
(1), first when opening the text, set its encoding format, such as: Open (' 1.txt ', encoding= ' GBK ');
(2), if (1) can not be resolved, may be the text appears in some special symbols beyond the GBK coding range, you can choose a wider range of coding ' GB18030 ', such as: Open (' 1.txt ', encoding= ' gb18030 ');
(3), if (2) still can not be resolved, the text appeared in the article even ' GB18030 ' can not be encoded characters, the use of the ' ignore ' attribute to ignore, such as: Open (' 1.txt ', encoding= ' gb18030 ', errors= ' ignore ');
(4) and a common workaround is open (' 1.txt '). Read (). Decode (' gb18030 ', ' ignore ')