首页 文章

这些代码有什么问题?Python3.6

提问于
浏览
-1

我无法弄清楚这两个代码有什么问题 . 我找不到任何区别 .

for id,level,sex,content,laugh,comment in zip(ids,levels,sexs.contents,laughs,comments):

这有效..

for id,level,sex,content,laugh,comment in zip(ids,levels,sexs,contents,laughs,comments):

这失败了......

回溯(最近一次调用最后一次):文件“G:/ pachong /爬虫/re_crawl.py”,第43行,在get_info(url)文件“G:/ pachong /爬虫/re_crawl.py”,第28行,在get_info中对于id,级别,性别,内容,笑,zip中的评论(ids,levels,sexs.contents,笑,评论):AttributeError:'list'对象没有属性'contents'

1 回答

  • 1

    您不小心输入了句号( . )而不是逗号( , ) . Python将其视为 sexs 对象上的属性查找 . 只需将 sexs.contents 更改为 sexs,contents 即可 .

相关问题