时间格式转化为时间戳保留秒级小数位(统一保留6位)

import datetime
dt = datetime.datetime.strptime(str("2020-06-14 23:03:15.163813"), '%Y-%m-%d %H:%M:%S.%f')
date_stamp =int(time.mktime(dt.timetuple()))
data_microsecond=dt.microsecond/1000000
date_stamp = date_stamp + data_microsecond
print(str(date_stamp))

 

    原文作者:onlyforbest
    原文地址: https://blog.csdn.net/onlyforbest/article/details/106753964
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞