将python datetime转换为具有可读格式date的字符串

f'{datetime.now():%H%M}'
在Python 3.6及更高版本中使用f字符串。

from datetime import datetime



date_string = f'{datetime.now():%Y-%m-%d %H:%M:%S%z}'


发布了381 篇原创文章 · 获赞 67 · 访问量 15万+

猜你喜欢

转载自blog.csdn.net/Arthur_Holmes/article/details/104209016