Day027.日期和时间的输出

'''
    日期和时间的输出
    @Ref 2017.Python语言程序设计基础.第2版.嵩天, p21
    @Version: v0.1, Python 3.9.5, Notus(hehe_xiao@qq.com), 2021.05.22
    @Updated: 2021.05.22
'''

from datetime import datetime           # 引用 datatime 库

now = datetime.now()                    # 获得当前日期和时间信息
print(now)
print(now.strftime("%x"))               # 输出其中的日期部分
print(now.strftime("%X"))               # 输出其中的时间部分

运行结果

2021-05-22 15:45:22.880423
05/22/21
15:45:22

posted @ 2021-05-22 16:12  Notus(Java)  阅读(56)  评论(0编辑  收藏  举报