S
S
sswwssww2019-12-24 15:51:38
Python
sswwssww, 2019-12-24 15:51:38

Why doesn't datetime.datetime.strptime want to work?

d = datetime.datetime.strptime('24.12.2019', '%d.%m.%Y')

" Traceback (most recent call last):
File "main.py", line 60, in
s = datetime.datetime.strptime(f'{d}', "%d.%m.%Y")
File "/usr /local/lib/python3.7/_strptime.py", line 577, in _strptime_datetime
tt, fraction, gmtoff_fraction = _strptime(data_string, format)
File "/usr/local/lib/python3.7/_strptime.py", line 359, in _strptime
(data_string, format))
ValueError: time data '2' does not match format '%d.%m.%Y
'"

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Elvis, 2019-12-24
@sswwssww

s = datetime.datetime.strptime(f'{d}', "%d.%m.%Y")
in this line you are passing in the variable d just the number 2.

V
Vladimir, 2019-12-24
@vintello

everything works for me

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question