‘gbk‘ codec can‘t decode byte 0x80 in position 2: illegal multibyte sequence

Read a text file on the script but report an error, the source code is as follows

threekingdomsFile=open('C:\\Users\\53469\\Desktop\\xfs\\python\\threekingdoms.txt','r');

Later, it was found that this was because of the encoding format, so it can be changed to the following form:

threekingdomsFile=open('C:\\Users\\53469\\Desktop\\xfs\\python\\threekingdoms.txt','r',100,'utf-8');

Guess you like

Origin blog.csdn.net/qq_34412985/article/details/124937055