0
点赞
收藏
分享

微信扫一扫

python 字符串转换为日期

吴wuwu 2023-04-19 阅读 78


str_ = '20231212'
datetime.datetime.strptime(str_, '%Y%m%d')# .strftime('%Y-%m-%d')

https://python3-cookbook.readthedocs.io/zh_CN/latest/c03/p15_convert_strings_into_datetimes.html

Python中的时间函数strftime与strptime对比

前者按指定格式输出字符串 后者将字符串输出为时间格式

https://zhuanlan.zhihu.com/p/387187779

举报

相关推荐

0 条评论