gpt4 book ai didi

python - 在从文件读取的列表中拆分\xef\xbb\xbf

转载 作者:太空宇宙 更新时间:2023-11-03 14:14:51 24 4
gpt4 key购买 nike

<分区>

我试图读取大数据 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。

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com