python--time
import datetime
#获取当前日期
def get_date():
date = datetime.datetime.strftime(datetime.datetime.now(),'%Y%m%d')
return date
#获取当前时间
def get_date_time():
date_time = datetime.datetime.strftime(datetime.datetime.now(),'%Y%m%d%H%M%S')
return date_time
#获取10位时间戳
def get_10_timestamp():
timestamp = datetime.datetime.timestamp(datetime.datetime.now())
timestamp_int = int(timestamp)
return timestamp_int
#时间戳转日期
def timestamp_transeto_time(timestamp):
result = datetime.datetime.fromtimestamp(timestamp)
return result
if __name__ == '__main__':
print(get_10_timestamp())
print(timestamp_transeto_time(get_10_timestamp()))