📜  在 python 中阅读文档 - 任何代码示例

📅  最后修改于: 2022-03-11 14:58:29.738000             🧑  作者: Mango

代码示例1
from bs4 import BeautifulSoup as bs
soup = bs(open(filename).read())
[s.extract() for s in soup(['style', 'script'])]
tmpText = soup.get_text()
text = "".join("".join(tmpText.split('\t')).split('\n')).encode('utf-8').strip()
print text