UnicodeDecodeError: 'gbk' codec can't decode byte 0x96 in position 2: illegal multibyte sequence

Given the information as follows

Code is given below

The reason given

Coding and encoding the file read the entire file is not set Python

solution

The first line sets

# _*_ coding:utf-8 _*_

Open the txt file to set the encoding format

open("data.txt",'r',encoding='UTF-8') 

 

 

 

Released 1185 original articles · won praise 310 · Views 1.17 million +

Guess you like

Origin blog.csdn.net/qq_37591637/article/details/103885475