**
报错’float’ object has no attribute 'decode’解决方法
**
在处理爬虫数据是,读取文本进行分词处理时
content_S = []
for line in text:
current_segment = jieba.lcut(line)#直接生成一列jieba.lcut 直接生成的就是一个list
if len(current_segment) > 1 and current_segment != '\r\n': #换行符
content_S.append(current_segment)
print(content_S[0])
AttributeError: ‘float’ object has no attribute ‘decode’
解决方法:在read_csv后面加上.astype(str)
df = pd.read_csv(fileee,usecols=['name1','text'],encoding='gbk').astype(str)#在read_csv后面加上.astype(str) ,不再报错。