我正在努力获得10条推特。我将计数设置为5,并应用“在范围(2)内”。这意味着它应该检索不超过10条tweet。但是,这里它给了我15条tweets,其中tweets id的tweets 1到5出现了两次
alltweet=[]
def rest_query_ex3():
query = "road"
geo = "42.6525,-73.7572,9mi"
MAX_ID = None
for it in range(2): # should Retrieve up to 10 tweets
tweets = myApi.search(q=query, geocode=geo, count=5, max_id=MAX_ID)
if tweets:
MAX_ID= tweets[-1].id
alltweet.extend(tweets)
for pk in alltweet:
print pk.id
if __name__ == '__main__':
rest_query_ex3()
在这张图片中,一些推特id正在重复,给了我超过10条推特。有人能在python中使用rest_api帮助我吗 enter image description here
这是您的
print
语句第一次在
loop
中,它将打印5
条推文下次它
prints
(5 + 5
)推特时所以这个
prints
总计15
推特也许您希望将}从另一个}中移出,如下所示:
print
{for
{相关问题 更多 >
编程相关推荐