0

I don't understand why I get this error using datetime.strptime(), shouldn't this match?

ValueError: time data '2018-02-01 15:09:02.487779' does not match format '%Y-$m-$d %H:%M:%S.%f'

Mimimal example would be:

from datetime import datetime
print(datetime.strptime('2018-02-01 15:09:02.487779', '%Y-$m-$d %H:%M:%S.%f'))

Thank you in advance!

1 Answer 1

3

You have dollar signs instead of percent signs in parts of your format string:

print(datetime.strptime('2018-02-01 15:09:02.487779', '%Y-$m-$d %H:%M:%S.%f'))
                                                          ^  ^
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.