如何在Python中解析非英语日期字符串?

时间:2021-01-10 07:12:24

I'm trying to parse some non-English datetime strings in Python. I've had success with Western European languages such as French, Spanish and Italian. However, for Czech, Finnish and Greek I have been unsuccessful.

我正在尝试用Python解析一些非英语日期时间字符串。我在西欧语言方面取得了成功,如法语,西班牙语和意大利语。但是,对于捷克语,芬兰语和希腊语,我没有成功。

I am setting the locale as follows:

我正在设置区域设置如下:

locale.setlocale(locale.LC_TIME, 'ell')

I've been unable to find any code examples online, or any documentation. Is there somewhere that the datetime model details what languages are supported?

我一直无法在线或任何文档找到任何代码示例。是否有某处datetime模型详细说明了支持哪种语言?

I am running on Windows.

我在Windows上运行。

Thanks.

1 个解决方案

#1


0  

Locales tend to use a combination of 2-digit ISO-639 language codes and 2-digit ISO-3166 country codes. Your example uses 'ell' for what I assume should be Greek; try el_GR instead. Similarly, Czech would be cs_CZ and Finnish fi_FI.

区域设置倾向于使用2位ISO-639语言代码和2位ISO-3166国家/地区代码的组合。你的例子使用'ell'来假设我应该是希腊语;试试el_GR。同样,捷克语将是cs_CZ和芬兰语fi_FI。

#1


0  

Locales tend to use a combination of 2-digit ISO-639 language codes and 2-digit ISO-3166 country codes. Your example uses 'ell' for what I assume should be Greek; try el_GR instead. Similarly, Czech would be cs_CZ and Finnish fi_FI.

区域设置倾向于使用2位ISO-639语言代码和2位ISO-3166国家/地区代码的组合。你的例子使用'ell'来假设我应该是希腊语;试试el_GR。同样,捷克语将是cs_CZ和芬兰语fi_FI。