soup.find\u all('a')函数将返回一个列表
例如
'''
> # [<a class="sister" href="http://example.com/elsie" id="link1">Elsie</a>,
> # <a class="sister" href="http://example.com/lacie" id="link2">Lacie</a>,
> # <a class="sister" href="http://example.com/tillie" id="link3">Tillie</a>]
'''
我想用这个列表来制作一个html文件
如果我使用for循环,它将只显示一个字符
还有什么可以列成清单的吗
'''
> # <a class="sister" href="http://example.com/elsie" id="link1">Elsie</a>
> # <a class="sister" href="http://example.com/lacie" id="link2">Lacie</a>
> # <a class="sister" href="http://example.com/tillie" id="link3">Tillie</a>
'''
删除[
和,
之后的</a>
和]
只需将其作为字符串输出并将其连接起来:
''.join()
基本上是这样做的:相关问题 更多 >
编程相关推荐