2024-04-27 02:47:25 发布
网友
我有以下声明:
for user in tweepy.Cursor(api.followers, screen_name=s, cursor=current_cursor).items():
但是,我不需要在第一次运行时运行, cursor=current_cursor。你知道吗
, cursor=current_cursor
我能想到的唯一方法是使用if语句来实现两个独立的for语句。你知道吗
有没有不那么草率的方法?你知道吗
if first_time: first_time = False cursor = tweepy.Cursor(api.followers, screen_names) else: cursor = tweepy.Cursor(api.followers, screen_name=s, cursor=current_cursor) for item in cursor.items(): whatever(item)
在适当的地方将first_time初始化为True。你知道吗
first_time
True
tweepy.Cursor(api.followers, screen_name=s, cursor=None if first_time else current_cursor)
在适当的地方将
first_time
初始化为True
。你知道吗相关问题 更多 >
编程相关推荐