时间数据与格式'%d%B%Y%H:%M'不匹配

时间:2015-01-28 01:02:46

标签: python google-app-engine datetime localization internationalization

E 02:30:01.337  Traceback (most recent call last):
  File "/base/data/home/apps/s~rssdeneme/1.381823925456087196/controllers/runk.py", line 34, in <module>
    pubDate = datetime.datetime.strptime((k.zaman).encode("iso-8859-9"),'%d %B %Y %H:%M'),))
  File "/base/data/home/runtimes/python27/python27_dist/lib/python2.7/_strptime.py", line 325, in _strptime
    (data_string, format))
ValueError: time data '24 Ocak 2015 00:00' does not match format '%d %B %Y %H:%M'

我尝试废弃网站并从中获取RSS。我在解析日期时遇到了困难。 gae在localhost工作,这些导入没有问题。

    import sys
    sys.path.append('libs/')
    reload(sys); sys.setdefaultencoding('utf-8')
    from bs4 import BeautifulSoup
    import locale
    locale.setlocale(locale.LC_ALL, '')
    import datetime
.....
pubDate = datetime.datetime.strptime((k.time).encode("iso-8859-9"),'%d %B %Y %H:%M'),))

但是当我部署到gae时它会出现此错误。我认为这是因为它从pc获取我的语言环境但它无法进入gae。我必须设置我的语言环境土耳其语我该怎么做?

尝试了

from locale import LC_ALL, setlocale
setlocale(LC_ALL,"Turkish") 

locale.setlocale(locale.LC_ALL, ('tr_TR', 'ISO8859-9')) 它给出了

 File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\python\stubs.py", line 82, in fake_set_locale

    raise locale.Error('locale emulation only supports "C" locale')

0 个答案:

没有答案