Skip to content

Datetime.strptime error in wxPython why #1637

@wstates

Description

@wstates
# coding=utf-8
import wx
import sys
import datetime

if __name__ == "__main__":
    print("wxpython version:", wx.version())
    print("Python version:", sys.version)
    print("Run before wx:", datetime.datetime.strptime("02/02/2020", '%d/%m/%Y'), "normal")
    app = wx.App()
    print("Run after wx:", datetime.datetime.strptime("02/02/2020", '%d/%m/%Y'), "error")

    # frame = MainFrame()
    # frame.SetSize(0, 0, 1200, 750)
    # frame.Center()
    # frame.Show()
    app.MainLoop()
wxpython version: 4.1.0 msw (phoenix) wxWidgets 3.1.4
Python version: 3.6.8 (tags/v3.6.8:3c6b436a57, Dec 24 2018, 00:16:47) [MSC v.1916 64 bit (AMD64)]
Run before wx: 2020-02-02 00:00:00 normal
Traceback (most recent call last):
  File "K:/test/a.py", line 14, in <module>
    print("Run after wx:", datetime.datetime.strptime("02/02/2020", '%d/%m/%Y'), "error")
  File "C:\Program Files\Python36\lib\_strptime.py", line 565, in _strptime_datetime
    tt, fraction = _strptime(data_string, format)
  File "C:\Program Files\Python36\lib\_strptime.py", line 334, in _strptime
    if (_getlang() != locale_time.lang or
  File "C:\Program Files\Python36\lib\_strptime.py", line 31, in _getlang
    return locale.getlocale(locale.LC_TIME)
  File "C:\Program Files\Python36\lib\locale.py", line 581, in getlocale
    return _parse_localename(localename)
  File "C:\Program Files\Python36\lib\locale.py", line 490, in _parse_localename
    raise ValueError('unknown locale: %s' % localename)
ValueError: unknown locale: zh-CN

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions