在BeautifulSoup

时间:2016-06-29 12:45:53

标签: css class replace find beautifulsoup

我有这个班级class = "good"。我需要用字符串替换它,比如style="word-wrap: break-word" width="400px"。整个字符串class = "good",字符串为style="word-wrap: break-word" width="400px"。我的实验find_allreplace_with不允许我使用所需的功能。无论如何可以实现吗?

1 个答案:

答案 0 :(得分:0)

这里不需要查找和替换,因为您需要更改此元素的属性而不是任何数据或html。

使用此

$('.good').css('word-wrap', 'break-word').attr('width','400px').removeAttr('class');