1、时间格式的转换
# 年月日时分秒格式
print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())))
# 年月日时分秒毫秒,精确到毫秒,一共20位,可以当时间戳来用
print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S:%f"))
# 年月日时分秒格式
print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())))
# 年月日时分秒毫秒,精确到毫秒,一共20位,可以当时间戳来用
print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S:%f"))
本文标题:python时间格式转换
本文链接:https://www.haomeiwen.com/subject/wmbyvftx.html
网友评论