【python】取得字符串形式的当前日期时间

代码:

#encoding=utf-8
import datetime

d=datetime.datetime.today()
dateStr=d.strftime('%Y-%m-%d_%H:%M:%S')
print("Current time=",dateStr)

输出:

C:\hy\py>python 04-currentDatetime.py
Current time= 2022-01-25_20:42:17

END

posted @ 2022-01-25 20:44  不朽的飞翔  阅读(653)  评论(0编辑  收藏  举报