美文网首页
python时间格式转换

python时间格式转换

作者: 五月的天at | 来源:发表于2020-08-20 18:04 被阅读0次

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"))

相关文章

网友评论

      本文标题:python时间格式转换

      本文链接:https://www.haomeiwen.com/subject/wmbyvftx.html