Python 将字符串时间转换为 时间戳

a = "2018-03-10 18:26:27.531"
d = datetime.datetime.strptime(a, "%Y-%m-%d %H:%M:%S.%f")
t = d.timetuple()
timeStamp = int(time.mktime(t))
print(timeStamp)
1520677587

1、 python timestamp和datetime之间的转换

http://blog.csdn.net/xxm524/article/details/48055275

2、Python 之 时间字符串、时间戳、时间差、任意时间字符串转换时间对象

https://www.cnblogs.com/liuq/p/6211005.html

3、Python时间,日期,时间戳之间转换

https://www.cnblogs.com/shgq/p/4065703.html

4、 python——时间与时间戳之间的转换

http://blog.csdn.net/google19890102/article/details/51355282

5、Python获取秒级时间戳与毫秒级时间戳

https://www.cnblogs.com/fangbei/p/python-time.html


你可能感兴趣的:(Python基础)