我正在使用这个不错的Python https://gist.github.com/BillyRobertson/06fd81c931834bdd297663d2add6ebf8为我的硕士论文抓取一些Reddit数据,我得到的.json数据如下:
{'author': 'xxxxxxxx',
'author_created_utc': 1373079085,
'author_flair_css_class': '',
'author_flair_text': 'Pro Choice',
'author_fullname': 't2_ca12v',
'body': "\n>Legally? No. But you certainly have the *right* to do so.\n\nNo you don't have the right. And if you did it wouldn't be illegal.",
'controversiality': 0,
'created_utc': 1454111259,
'distinguished': None,
'gilded': 0,
'id': 'czh0sct',
'link_id': 't3_435gui',
'nest_level': 5,
'parent_id': 't1_czgyyl5',
'reply_delay': 3057,
'retrieved_on': 1454817532,
'score': 0,
'stickied': False,
'subreddit': 'prolife',
'subreddit_id': 't5_2qscv'}我怎样才能知道这篇文章写在哪一天(例如03.04.2021)?
非常感谢!
发布于 2022-04-16 06:47:13
如果您的数据存储在变量d中,您应该能够这样做:
from datetime import datetime
date = datetime.utcfromtimestamp(d['author_created_utc'])如果您只关心日期,而不需要将其作为datetime对象处理,则可以使用以下方法:
date = datetime.utcfromtimestamp(d['author_created_utc']).strftime('%Y-%m-%d')https://stackoverflow.com/questions/71891681
复制相似问题