小编use*_*554的帖子

Python文本处理:AttributeError:'list'对象没有属性'lower'

我是Python和Stackoverflow的新手(请温柔),我正在努力学习如何进行情绪分析.我正在使用我在教程中找到的代码组合,这里:Python - AttributeError:'list'对象没有属性但是,我一直在

Traceback (most recent call last):
    File "C:/Python27/training", line 111, in <module>
    processedTestTweet = processTweet(row)
  File "C:/Python27/training", line 19, in processTweet
    tweet = tweet.lower()
AttributeError: 'list' object has no attribute 'lower'`
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

import csv
#import regex
import re
import pprint
import nltk.classify


#start replaceTwoOrMore
def replaceTwoOrMore(s):
    #look for 2 or more repetitions of character
    pattern = re.compile(r"(.)\1{1,}", re.DOTALL)
    return pattern.sub(r"\1\1", s)

# process the tweets
def processTweet(tweet):
    #Convert to lower case
    tweet = tweet.lower()
    #Convert www.* …
Run Code Online (Sandbox Code Playgroud)

python csv text-classification

9
推荐指数
1
解决办法
4万
查看次数

标签 统计

csv ×1

python ×1

text-classification ×1