【Python】时间与时间戳
作者:互联网
code
import time #获取10位时间戳 t=time.time() print(int(t)) #获取13位时间戳 temp=time.time() timestamp=int(round(temp*1000)) print(timestamp) #日期转时间戳 dt="2020-12-29 18:13:21" timearray=time.strptime(dt,"%Y-%m-%d %H:%M:%S") timestamp=time.mktime(timearray) tmp_stamp=int(timestamp) print(tmp_stamp)
输出
macname@MacdeMacBook-Pro Desktop % python3 xxxxx.py 1609237378 1609237378025 1609236801 macname@MacdeMacBook-Pro Desktop %
标签:Python,timestamp,Desktop,int,时间,MacdeMacBook,time,print 来源: https://www.cnblogs.com/sea-stream/p/14208097.html