lzjun567 / python_scripts

一些python相关的演示代码
Apache License 2.0
716 stars 527 forks source link

给h1标签设置居中 body.find('h1')['style'] = "text-align:center;" #21

Open pendave opened 7 years ago

pendave commented 7 years ago
#给 h1 tag 设置居中属性
body.find('h1')['style'] = "text-align:center;"

这时候要用

body = soup.find(class_="article-intro")

#body = soup.find_all(class_="article-intro") #如果用find_all 那后面就要用 html = h[1:-1] 去掐头去尾 去掉 [ 和 ]
pendave commented 7 years ago

find_all 我也试了下 可以这样写 qq 20170526001233 效果可以: qq 20170526001821