【发布时间】:2016-03-22 04:07:07
【问题描述】:
我尝试读取大数据file.txt并拆分所有逗号、点等,所以我在Python中使用以下代码读取文件:
file= open("file.txt","r")
importantWords =[]
for i in file.readlines():
line = i[:-1].split(" ")
for word in line:
for j in word:
word = re.sub('[\!@#$%^&*-/,.;:]','',word)
word.lower()
if word not in stopwords.words('spanish'):
importantWords.append(word)
print importantWords
它打印了['\xef\xbb\xbfdataText1', 'dataText2' .. 'dataTextn']。
如何清理\xef\xbb\xbf?我正在使用 Python 2.7。
【问题讨论】:
-
您是否费心寻找那个特定的字符串?
标签: python python-2.7 stop-words