Python在读取文件时
with open('location_data.txt', "r") as f: # 打开新的文本
data = f.read() # 读取文本数据
出现错误:
UnicodeDecodeError: 'gbk' codec can't decode byte 0xaa in position 7236: illegal multibyte sequence
解决办法:
加上字符的编码格式,避免出错
with open('location_data.txt','r',encoding='UTF-8') as f: # 打开新的文本
data = f.read() # 读取文本数据