当前位置:主页 > 软件编程 > Python代码 >

python日期时间转为字符串或者格式化输出的实例

时间:2021-02-15 10:20:43 | 栏目:Python代码 | 点击:

如下所示:

年月日时分秒

>>> print datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
2017-07-15 15:01:35

年月日 小时分钟

>>> print datetime.datetime.now().strftime("%Y-%m-%d %H:%M")
2017-07-15 15:01

年月日

>>> print datetime.datetime.now().strftime("%Y%m%d")
20170715

您可能感兴趣的文章:

相关文章