下面这段代码会报错:
from datetime import datetime
ts = 1571595618.0
x = datetime.utcfromtimestamp(ts)
x_ts = x.timestamp()
assert ts == x_ts, f"{ts} != {x_ts}"
换成这样就对:
from datetime import datetime, timezone
ts = 1571595618.0
x = datetime.fromtimestamp(ts, tz=timezone.utc)
x_ts = x.timestamp()
https://blog.ganssle.io/articles/2019/11/utcnow.html
--
FROM 59.60.24.*