我试图做一个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)
答案 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
已经是帖子列表。