python 3.7 进行字符串转时间时报 ValueError('unknown locale: %s' % localename)
报错信息:
self.all_list = self.init_data("")
File "F:/pycharmProject/auto/download_new.py", line 440, in init_data
print(time.strptime(str,"%Y-%m-%d %H:%M:%S"))
File "C:\Python37\lib\_strptime.py", line 277, in <module>
_TimeRE_cache = TimeRE()
File "C:\Python37\lib\_strptime.py", line 191, in __init__
self.locale_time = LocaleTime()
File "C:\Python37\lib\_strptime.py", line 69, in __init__
self.lang = _getlang()
File "C:\Python37\lib\_strptime.py", line 28, in _getlang
return locale.getlocale(locale.LC_TIME)
File "C:\Python37\lib\locale.py", line 591, in getlocale
return _parse_localename(localename)
File "C:\Python37\lib\locale.py", line 499, in _parse_localename
raise ValueError('unknown locale: %s' % localename)
ValueError: unknown locale: zh-CN
datetime.strptime 、time.strptime 都报同样的错误
time.strptime(‘2020-08-11 10:08:02’,’%Y-%m-%dT%H:%M:%S’)
datetime.strptime(‘2020-08-11 10:08:02’,’%Y-%m-%dT%H:%M:%S’),此时报下面错误: