A format error occurs when trying to display the string in time.
result3 = ''.join(file_name)
date_time_str = result3
result1 = datetime.datetime.strptime(date_time_str, '%Y-%m-%d %H:%M:%S')
print(result1)
The problem here is ValueError: time data '20220308233355' does not match format '%Y-%m-%d %H:%M:%S' There is an error, did I enter the wrong format? My 20220308233355 I want to mark yyyy-mm--dd hh:mm:ss.
python
# str => datetime
object.strftime('yyyymmddhhmmss')
# # datetime => str
object.strptime('yyyy-mm--dd hh:mm:ss')
© 2024 OneMinuteCode. All rights reserved.