gpt4 book ai didi

python - 字符串到日期时间

转载 作者:太空狗 更新时间:2023-10-30 02:14:07 25 4
gpt4 key购买 nike

我将 datetime.datetime.now() 保存为字符串。现在我有一个字符串值,即

2010-10-08 14:26:01.220000

如何将这个字符串转换成

Oct 8th 2010

?

谢谢

最佳答案


from datetime import datetime
datetime.strptime('2010-10-08 14:26:01.220000'[:-7],
'%Y-%m-%d %H:%M:%S').strftime('%b %d %Y')

关于python - 字符串到日期时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3894462/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com