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