python 时间转时间戳,时间戳转时间
import datetime
import time
class Util:
@staticmethod
def datetime_timestamp(d: datetime.datetime):
"""
时间转换成时间戳
:param d:
:return:
"""
return time.mktime(d.timetuple())
@staticmethod
def timestamp_datetime(stamp: float):
"""
时间戳转换成时间
:param stamp:
:return:
"""
return datetime.datetime.fromtimestamp(stamp)
还没有评论,来说两句吧...