更新时间:2023-01-29 16:58:50
写这样的东西应该将 Twitter 日期转换为时间戳.
Writing something like this should convert a twitter date to a timestamp.
import time
ts = time.strftime('%Y-%m-%d %H:%M:%S', time.strptime(tweet['created_at'],'%a %b %d %H:%M:%S +0000 %Y'))
更新
对于 Python 3,从 2020 年开始,您可以这样做:
For Python 3, as per 2020, you can do it in this way:
from datetime import datetime
# dtime = tweet['created_at']
dtime = 'Fri Oct 09 10:01:41 +0000 2015'
new_datetime = datetime.strftime(datetime.strptime(dtime,'%a %b %d %H:%M:%S +0000 %Y'), '%Y-%m-%d %H:%M:%S')
print((new_datetime))