我使用beauthoulsoup将html文件中的所有逗号替换为‚
。这是我的代码:
f = open(sys.argv[1],"r")
data = f.read()
soup = BeautifulSoup(data)
comma = re.compile(',')
for t in soup.findAll(text=comma):
t.replaceWith(t.replace(',', '‚'))
除非html文件中包含一些javascript,否则这些代码可以正常工作。在这种情况下,它甚至将javascript代码中的逗号(,)替换为。这不是必需的。我只想替换html文件的所有文本内容。在
^{} 可以调用:
相关问题 更多 >
编程相关推荐