Python3 | 13 位 unix 时间戳的方法

Posted by Haauleon on May 16, 2022

代码设计

10 位时间戳
1
2
3
4
5
6
7
>>> import time
>>> t = time.time()
>>> print t
1436428326.76
>>> print int(t)
1436428326
>>> 


13 位时间戳
1
2
3
import time
millis = int(round(time.time() * 1000))
print millis
1
2
3
4
5
6
import time

current_milli_time = lambda: int(round(time.time() * 1000))
Then:
>>> current_milli_time()
1378761833768