【发布时间】:2018-01-27 01:54:16
【问题描述】:
我知道用 python BeautifulSoup 写这样的新标签:
# create new_div
new_div = soup.new_tag("div", id="description", style="float:left")
# insert it into the document
soup.body.append(new_div)
但我在添加类属性时出错,语法无效:
new_div = soup.new_tag("div", class="description", style="float:left") ^ SyntaxError: 无效语法
创建新标签时如何添加类属性的正确方法?
谢谢
【问题讨论】:
标签: python beautifulsoup