公司在选择网站时应考虑什么问题,wordpress 标题优化,百度运营怎么做,h5制作素材我无法将从多个html文件(文本不是英文)获得的正则表达式结果写入.txt文件。它将它们打印成屏幕上新行的几个字符串#xff0c;但是当我尝试将它写入outfile时#xff0c;它只会写入一个随机字符串。我的代码看起来像这样#xff1a; 你能帮我怎么把所有的字符串写入所有大约…我无法将从多个html文件(文本不是英文)获得的正则表达式结果写入.txt文件。它将它们打印成屏幕上新行的几个字符串但是当我尝试将它写入outfile时它只会写入一个随机字符串。我的代码看起来像这样 你能帮我怎么把所有的字符串写入所有大约100个文件的outfile中吗将多个html文件的正则表达式结果写入.txt outfilefrom bs4 import BeautifulSoupimport sysimport stringimport reimport ostext glob.glob(C:/Users/dell/Desktop/python-for-text-analysis-master/Notebooks/MEK/*)for filename in text:with open(filename, encodingISO-8859-1, errorsignore) as f:mytext f.read()soup BeautifulSoup(mytext, lxml)extracted_text soup.getText()pattern r\ba\b\s\bleg[\w]bb\b\s\b[\w]\bresult (, .join(re.findall(pattern, mytext)))file C:/Users/dell/Desktop/python-for-text-analysis-master/Data/Charlie/charlie_neww.txtfor row in result:with open (file, w, encodingiso-8859-1, errorsignore) as outfile:print(result, end\n, fileoutfile)2017-02-09Lee0我不认为你的意思是打印(结果)...... –2017-02-09 21:46:150呃等等......结果是一个字符串.....你认为结果中的行在做什么因为我怀疑它在做你认为正在做的事情。 –2017-02-09 21:47:27