UnicodeDecodeError: 'utf-8' codec can't decode byte 0x92
- python2中没问题
读取文件不是'utf-8'编码
先以二进制方式读取,再转换为utf-8编码(忽略特殊字符造成的转码错误)
# open('email/spam/17.txt', 'rb').read().decode('utf8','ignore')
TypeError: 'range' object doesn't support item deletion
解决办法:将dataIdex = range(m) 改为
dataIndex = list(range(m))
- 原因:python3.x range返回的是range对象,不返回数组对象


网友评论