python学习——python datetime转13位时间戳(精确到毫秒)

参考代码如下所示:

from datetime import datetime
dtime = datetime(2018, 1, 1, 20)
print("Datetime: ", dtime)
 
dtimestamp = dtime.timestamp()
print("Integer timestamp in seconds: ",
      int(round(dtimestamp)))
 
milliseconds = int(round(dtimestamp * 1000))
print("Integer timestamp in milliseconds: ",
      milliseconds)

参考链接:https://www.geeksforgeeks.org/python-datetime-to-integer-timestamp/

你可能感兴趣的:(工具介绍,python学习,学习)