从响应中,我得到了类似'1663935188183'
的日期时间戳。我使用了pythondatetime.fromtimestamp()
函数,并以完整格式'2022-09-23 14:13:08.183000'
打印日期
我的问题是,我能从上面的函数中提取出小时、分钟和秒吗?
您可以尝试此解决方案
>> from datetime import datetime
# Be carefule this will raise ValueError: year 54698 is out of range
# you have to divide timestamp by 1e3 if your timestamp is in milliseconds
>> timestamp = 1663935188183/1e3
>> date = datetime.fromtimestamp(timestamp)
>> date.hour, date.minute, date.second
(14, 13, 8)