im trying to analyze the amount of titles and the time in a subreddit with Python. But i cant convert the UTC time to datetime
here is my code
hotPython = subreddit.hot(limit=4)
for i in hotPython:
print(i.created_utc)
and i get back this results
1523290473.0
1521831644.0
1523750525.0
1523747490.0
i tried different thing to convert, but i dont get it
would appreciate if somebody can help
If you're able to get the epoch time, you can convert this to a datetime
using datetime.fromtimestamp
.
For example:
from datetime import datetime
t = 1523290473.0
dt = datetime.fromtimestamp(t)
Then dt
is a datetime
as desired.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.