最佳答案
我需要从 Ref = “ https://developer.twitter.com/en/docs/twitter-api/v1/data-dictionary/object-model/tweet”rel = “ noReferrer”> create _ at 属性返回的 Datetime.datetime对象中提取一天中的时间,但是我怎么做呢?
这是获取 datetime.datetime 对象的代码。
from datetime import *
import tweepy
consumer_key = ''
consumer_secret = ''
access_token = ''
access_secret = ''
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_secret)
api = tweepy.API(auth)
tweets = tweepy.Cursor(api.home_timeline).items(limit = 2)
t1 = datetime.strptime('Wed Jun 01 12:53:42 +0000 2011', '%a %b %d %H:%M:%S +0000 %Y')
for tweet in tweets:
print (tweet.created_at - t1)
t1 = tweet.created_at
我只需要从 t1
中提取小时和分钟。