- Python 3.9.12(32位(
- Windows 10(32位(
当我尝试获取datetime对象时,我收到了如下错误。
import datetime
dt_str = "2022-09-13 14:23:10"
dt = datetime.datetime.strptime(dt_str, "%Y-%m-%d %H:%M:%S")
"""
Traceback (most recent call last):
File "_strptime.py", line 268, in <module>
File "_strptime.py", line 182, in __init__
File "_strptime.py", line 69, in __init__
File "_strptime.py", line 28, in _getlang
File "locale.py", line 593, in getlocale
File "locale.py", line 501, in _parse_localename
ValueError
:
unknown locale: ko-KR
"""
因此,我再次尝试检查当前的区域设置,但出现了相同的错误。
import locale
print(locale.getlocale())
"""
Traceback (most recent call last):
File "locale.py", line 593, in getlocale
File "locale.py", line 501, in _parse_localename
ValueError
:
unknown locale: ko-KR
"""
它怎么了?
我认为您的时区设置不正确。尝试使用:
locale.setlocale(locale.LC_ALL, 'ko_KR.utf8')