TypeError: sequence item 0: expected string, Tag found

Posted xuchunlin

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了TypeError: sequence item 0: expected string, Tag found相关的知识,希望对你有一定的参考价值。

原始代码:

soup = BeautifulSoup(result, html.parser)
content_list = soup.find_all(p, attrs={"class": "art_p"})
content = <br/>.join(content_list)

 

报错内容是:

Traceback (most recent call last):
  File "G:/squid_frame/app_spider/spider_3_sina/sina_2_content_spider.py", line 169, in <module>
    sina_content_spider(item=item)
  File "G:/squid_frame/app_spider/spider_3_sina/sina_2_content_spider.py", line 107, in sina_content_spider
    content = <br/>.join(content_list)
TypeError: sequence item 0: expected string, Tag found

 

解决办法:

soup = BeautifulSoup(result, html.parser)
content_list = soup.find_all(p, attrs={"class": "art_p"})
content =  <br>.join(str(ii) for ii in content_list)

 

以上是关于TypeError: sequence item 0: expected string, Tag found的主要内容,如果未能解决你的问题,请参考以下文章

python报错:TypeError: sequence item 0: expected str instance, int found

argument 1 must be 2-item sequence, not int

UVM序列篇之二:sequence和item(上)

uvm模型中get不同时序的item怎么实现

TypeError:无法腌制 dict_items 对象

python3错误之TypeError: 'dict_items' object is not callable