> import time
> time.strptime(time_stamp, '%x %X')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.8/_strptime.py", line 562, in _strptime_time
tt = _strptime(data_string, format)[0]
File "/usr/lib/python3.8/_strptime.py", line 349, in _strptime
raise ValueError("time data %r does not match format %r" %
ValueError: time data '24. jan. 2021 kl. 19.48 ' does not match format '%x %X'
An experiment demonstrating the issue.
Even though '%x %X' is used to format the time stamp, the resulting time stamp string can not be parsed using this same format.
$ sudo apt install language-pack-nb
$ python3.8
> import locale setlocale( locale. LC_ALL, 'nb_NO.UTF-8')
> locale.
'nb_NO.UTF-8'
> import datetime datetime. now().strftime( '%x %X')
> time_stamp = datetime.
> time_stamp
'24. jan. 2021 kl. 19.48 '
> import time time_stamp, '%x %X')
> time.strptime(
Traceback (most recent call last): python3. 8/_strptime. py", line 562, in _strptime_time data_string, format)[0] python3. 8/_strptime. py", line 349, in _strptime
File "<stdin>", line 1, in <module>
File "/usr/lib/
tt = _strptime(
File "/usr/lib/
raise ValueError("time data %r does not match format %r" %
ValueError: time data '24. jan. 2021 kl. 19.48 ' does not match format '%x %X'