python因?yàn)閡tc時(shí)間习瑰、服務(wù)器時(shí)間不同會(huì)在時(shí)間時(shí)區(qū)處理上容易有問題沸枯,得注意帝美。
個(gè)人嘗試成功:
import time
#為當(dāng)前時(shí)間到當(dāng)天0點(diǎn)的秒數(shù)潦蝇、86400為1天的秒數(shù)番捂、北京時(shí)間的time.timezone值是-28800,所以是+
int(time.time()-time.timezone) %86400
#當(dāng)天0點(diǎn)時(shí)間戳
zeroPoint = int(time.time()) -int(time.time()-time.timezone) %86400
#昨天0點(diǎn)時(shí)間戳
yesterdayZeroPoint = zeroPoint - 86400