我这几天才刚刚学了python,准备从网上找个程序提取单词
我照着百度打的
文章原文链接:python编程从文章中提取英文单词
报错截图
import re
list_wenzhang=[]
text=""
a=open("01.txt","r")
list_wenzhang=a.readlines()
hang_shu=len(list_wenzhang)
j=0
for j in range(hang_shu):
text=text+list_wenzhang[j]
list_danci=(re.findall("[a-zA-Z]+",text)
def text_save(filename,data):
file = open(filename,"a")
for i in range(len(data)):
s = str(data[i]).replace("[",""),replace("]","")
s = s.replace(" ","") #去除空格
file.write(s)
file.close()
print("保存文件成功")
text_save("00.txt",list_danci)
来源:CSDN
作者:Look here
链接:https://blog.csdn.net/youthfulin/article/details/104261688