github:https://github.com/MichaelBeechan
CSDN:https://blog.csdn.net/u011344545
file = open(filename, "r")
for line in file: #every line is a poem
#print(line)
title, poem = line.strip().split(":") #get title and poem
出现UnicodeDecodeError:
File "F:\MichaelProject\Chinese_poem\dataPretreatment.py", line 13, in pretreatment
for line in file: #every line is a poem
UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 29: illegal multibyte sequence
修改:
file = open(filename, "r", encoding='UTF-8')# add encoding='UTF-8'
for line in file: #every line is a poem
按照上述修改可以使得程序成功运行