伙计们,我使用此代码提取推特数据,我想将 created_at 导出为日、月和年,没有小时信息,但我得到了这个Fri Jul 02 01:07:43 +0000 2021我想得到这个2021 年 2 月 6 日
from TwitterSearch import *
try:
ts = TwitterSearch(
consumer_key = consumer_key,
consumer_secret = consumer_secret,
access_token = access_token,
access_token_secret = access_token_secret)
tso = TwitterSearchOrder() #Cria objeto do TwitterSearchOrder
tso.set_keywords(['teste'], or_operator = True)
tso.set_language('pt')
for tweet in ts.search_tweets_iterable(tso):
print('created_at:', tweet['created_at'], 'User_id: ', tweet['id_str'], 'Tweet: ',tweet['text'])
created_at = tweet['created_at']
user_id = tweet['id_str']
texto = tweet['text']
with open('tweet.json', 'a+') as output:
data = { 'created_at': created_at,
'User_id': user_id,
'tweet':texto
}
output.write('{}\n'.format(json.dumps(data)))
except TwitterSearchException as e:
print(e)
你知道如何解决吗?