with open(os.path.join(new_folder_path, file), 'r') as fp:
raw = fp.read()
File "C:/python Project/text_categorization.py", line 40, in text_processing
raw = fp.read()
UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 4: illegal multibyte sequence
文件的编码方式是utf-8码,要转换成unicode码(python用的码)必须使用utf-8的编码法则,在这里默认是使用gbk的编码法则,所以要把with open(os.path.join(new_folder_path, file), ‘r’) 改成with open(os.path.join(new_folder_path, file), ‘r’,encoding=‘utf-8’) 才能成功编码
ps:python36(python36的函数库和2有很多不同)