質問

I have written a Python script that uploads 6 URL's in each tweet to Twitter. I use the user_timeline() API call to pull down all the posts that are made, effectively shortening the URL's that I posted to twitters t.co URL's.

My problem is that the user_timeline() call does not order the tweets chronologically.

In a Twitter timeline the most recent tweet is posted at the top. I would prefer it, if I could read back the timeline from the bottom, which is where my first tweet would start.

This is the code I'm using to retrieve the tweets on my timeline from twitter:

user_tweets = api.user_timeline()
for tweet in user_tweets:
    print tweet.text

Does anyone have an idea of how I can use tweepy or just the twitter REST API to reverse the order of how it retrieves the tweet?

役に立ちましたか?

解決

You can reverse the list and print it out that way

for tweet in reversed(user_tweets):
    print tweet.text
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top