列表”对象没有属性“统计信息”

时间:2019-11-14 10:47:31

标签: python python-3.x bots

我试图做一个TikTok python脚本,但是首先我需要打印帖子。我不能这样做,因为“'列表'对象没有属性'统计'”。我该怎么解决?

from tiktok_bot import TikTokBot
from pydantic import BaseModel


bot = TikTokBot()

print(bot)

my_feed = bot.list_for_you_feed(count=20)

print(my_feed)

popular_posts = [my_feed]
for post in popular_posts:
  if post.statistics.play_count > 1_000_000:
    print(popular_posts)

most_liked_posts = [my_feed]
for post in most_liked_posts:
  if post.statistics.digg_count > 200_000:
    print(most_liked_posts)     

most_shared_posts = [my_feed]
for post in most_shared_posts:
  if post.statistics.share_count > 5_000:
    print(most_shared_posts)

1 个答案:

答案 0 :(得分:1)

popular_posts = [my_feed]
for post in popular_posts:
  if post.statistics.play_count > 1_000_000:
    print(popular_posts)

应该是

popular_posts = [post for post in my_feed if post.statistics.play_count > 1_000_000]
print(popular_posts)

这是因为my_feed已经是帖子列表。