import time # 时间戳 转化为 datetime 类型 # # b = time.time() # b = time.localtime(b) # b = time.strftime("%Y-%m-%d %H:%M:%S",b) # print(b) # 2022-11-07 16:06:49 # 将 datetime 类型 转化为 时间戳 # b = int(time.mktime((datetime.now()).timetuple())) # # print(b) # 1667808733 # 格式化datetime类型 # b = datetime.strftime(datetime.now(), '%Y%m%d%H%M%S') # print(b) # 20221107162254
# 可以将字符类型转为时间类型
datetime = datetime.strptime( '2022-11-14 17:23:02', "%Y-%m-%d %H:%M:%S" )