[英]python - how to display time as epoch?
I need to display the current time as an epoch in python to pass as a variable into some code how do I go about doing that?我需要将当前时间显示为 python 中的一个纪元,以作为变量传递给某些代码,我该怎么做?
ie. IE。 1458410416
Every method of每一种方法
import datetime
datetime.datetime()
gives human readable values.给出人类可读的值。
Import the time
library, and then use this code:导入time
库,然后使用以下代码:
>>> time.mktime(datetime.datetime.now().timetuple())
1458410651.0
time.mktime
converts a datetime
to a Unix epoch timestamp. time.mktime
将datetime
时间转换为 Unix 纪元时间戳。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.