简体   繁体   中英

time data '2021-03-31 23:30:00' does not match format '%Y-%m-%d %H:%M:S'

This simple example brings the error described above.

from datetime import datetime
obj = datetime.strptime('2021-03-31 23:30:00',  '%Y-%m-%d %H:%M:S')

Any help will be appreciated. Thanks

You're missing a % for the S-part

from datetime import datetime
obj = datetime.strptime('2021-03-31 23:30:00',  '%Y-%m-%d %H:%M:%S')

You're missing a % at the seconds. Should be

'%Y-%m-%d %H:%M:%S'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM