python 字符串转换为日期

吴wuwu

关注

阅读 83

2023-04-19


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)

0 0 举报