Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > de.comp.lang.python > #4600

Re: [Python-de] Datetime frage

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Hans-Peter Jansen <hpj@urpla.net>
Newsgroups de.comp.lang.python
Subject Re: [Python-de] Datetime frage
Date Sun, 11 Dec 2016 21:01:01 +0100
Lines 71
Message-ID <mailman.12.1481486471.2322.python-de@python.org> (permalink)
References <o2k666$fir$1@tota-refugium.de> <1517572.IuxMI0Hij7@xrated>
Mime-Version 1.0
Content-Type text/plain; charset="iso-8859-1"
Content-Transfer-Encoding quoted-printable
X-Trace news.uni-berlin.de kuYWAJvYHJEV9yg8QymG6QD7KZhgyLVt0YGIpDtJsKVQ==
Return-Path <hpj@urpla.net>
X-Original-To python-de@python.org
Delivered-To python-de@mail.python.org
X-Virus-Scanned amavisd-new at lisa.loc
User-Agent KMail/4.14.10 (Linux/4.8.12-3-default; KDE/4.14.26; x86_64; ; )
In-Reply-To <o2k666$fir$1@tota-refugium.de>
X-Provags-ID V03:K0:WHMpX7ReOg5dROuhL4J127DWp32Bgtu3ddv9YS/Fl0BJ+JU9Bvw j4ABMxqSQ6+KYp/+ykRw8xCvRTnBDrhr82EWj5OCa9N/O2T+VzGm0etrOWKDrJ2XraHp52k TtJMdZQE0KuMGXvXGESBOdcFlDk+fL+P+/dLyNn/klGfkuM5iz4pmTKgXKiQan90wNYfvoC gqxPhWGyYC0bjcU2cfjBw==
X-UI-Out-Filterresults notjunk:1;V01:K0:B+HkRwY2WE8=:jblNkTnpRgvmCdxvzewgPc emIGzs38UdkGM4oy4n0UWNwMdT7qrKdufqigXVbe5abZVoqvolItKT92GVAcPGQiq3zT4iOp+ K2zFblknnGjPAgXPeScaKQHybNgUXwfIFUKuVr+sq8iSZuT7h5I3w9yAK6176vnSbDmrPTbR3 DtzsuURNU/mzthFnibvuQCkpunFXMkS9fTB2L3v5kMb815turf2B+9kfBpebK5hCh+PiIrWA2 pt6ZXZfcjVu5XqEi8QLLbJ1p6ZFTHEE24fWyyWkMBJmGFrlqLgBwbdfJUKsFWzUIGYQ2Puzon 7mH4kNNOw6eMQOFxNwrE6gxPr0dXYN0UzjVUBZnrAySj0ibFwUJlpH5fL38HUXqQ7YQDjnv3W Ybi7dNeZdEA6fjRkLPL8opwU6o36W+8gSRq++8mPg+nSmz7blh+8B26Z6WEJMfdA2zUihQtEM x061i6072qMc+yzkHewpEx9vMrtQ6Pr57/uHUABmbu5K03/I0hD9CD4/XrgIR3J6ndmSOawC7 ypSFV/KrY8FICoGHZLENZJC3zcxeNKaOQu/vhdaGCknNa0ynv43RFP2+7/9NnfhvbN0840tWg cmSSJxWyeiOqAAVeAI9uI3j2s4ZKHM24MvUl4TvYg5adV2zpEOnUl8Mc6R8fJjeBnCISCzJNo XEI4rIbbn5q8r/dW9qIOdRKJKyrMveKlE9EPja4Va/D/gDfgDZ2w1W1opRhLYG0K+fGWSoPca NuD2+zhI+MqOxFyZ
X-Content-Filtered-By Mailman/MimeDel 2.1.23
X-BeenThere python-de@python.org
X-Mailman-Version 2.1.23
Precedence list
List-Id Die Deutsche Python Mailingliste <python-de.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-de>, <mailto:python-de-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-de/>
List-Post <mailto:python-de@python.org>
List-Help <mailto:python-de-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-de>, <mailto:python-de-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <1517572.IuxMI0Hij7@xrated>
X-Mailman-Original-References <o2k666$fir$1@tota-refugium.de>
Xref csiph.com de.comp.lang.python:4600

Show key headers only | View raw


On Sonntag, 11. Dezember 2016 18:33:42 Manfred Gil wrote:
> Hallo Liste,
> 
> ich spiele gerade mit Datetime rum, um das Modul verstehen zu können.
> Dabei viel mir auf das ich nur die Englische Bezeichnung bekomme.
> 
> <Beispiel>
> 
> import datetime as dt
> 
> heute = dt.date.today()
> 
> print("Heute ist = ",heute)
> 
> print(heute.strftime("%A %d. %B %Y")) # Tag und Monat ist in English
> 
> import locale
> 
> print(locale.getlocale())
> 
> </Beispiel >
> 
> Die Ausgabe bei mir lautet:
> 
> Heute ist =  2016-12-11
> Sunday 11. December 2016
> ('de_DE', 'UTF-8')
> 
> 
> Frage:
> Wie bringe ich datetime bei, die Ausgabe in Deutsch zu schreiben, ich dachte
> ( so hab ich es verstanden ) das, wenn locale richtig gesetz ist, die
> Ausgabe auf Deutsch erscheinen sollte.

Dann mach das doch mal:

--> import locale
--> locale.setlocale(locale.LC_ALL, '')
'de_DE.UTF-8'
--> import datetime as dt
--> heute = dt.date.today()
--> print(heute.strftime("%A %d. %B %Y"))
Sonntag 11. Dezember 2016
--> print(locale.getlocale())
('de_DE', 'UTF-8')

und probiere das mit beiden pythons.

Wenn Du unbedingt setlocale selber zusammenbauen willst, dann so:

Python 3.4.5 (default, Jul 03 2016, 12:57:15) [GCC] on linux
Type "help", "copyright", "credits" or "license" for more information.
--> import locale
--> import datetime as dt
--> heute = dt.date.today()
--> print(heute.strftime("%A %d. %B %Y"))
Sunday 11. December 2016
--> locale.setlocale(locale.LC_ALL, 'de_DE.UTF-8')
'de_DE.UTF-8'
--> print(locale.getlocale())
('de_DE', 'UTF-8')
--> print(heute.strftime("%A %d. %B %Y"))
Sonntag 11. Dezember 2016

Aber wer will das schon... ;)

Viel Glück,
Pete

Back to de.comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Datetime frage Manfred Gil <manfred-gil@t-online.de> - 2016-12-11 18:33 +0000
  Re: [Python-de] Datetime frage "Andreas Jung" <lists@zopyx.com> - 2016-12-11 19:39 +0100
    Re: [Python-de] Datetime frage Manfred Gil <manfred-gil@t-online.de> - 2016-12-11 19:20 +0000
      Re: [Python-de] Datetime frage "Andreas Jung" <lists@zopyx.com> - 2016-12-11 20:29 +0100
        Re: [Python-de] Datetime frage Hans-Georg Joepgen <test@joepgen.com> - 2016-12-11 20:49 +0100
          Re: [Python-de] Datetime frage "Andreas Jung" <lists@zopyx.com> - 2016-12-11 20:56 +0100
      Re: [Python-de] Datetime frage Christopher Arndt <chris@chrisarndt.de> - 2016-12-11 20:53 +0100
      Re: [Python-de] Datetime frage Stefan Schwarzer <sschwarzer@sschwarzer.net> - 2016-12-11 21:03 +0100
        Re: [Python-de] Datetime frage Manfred Gil <manfred-gil@t-online.de> - 2016-12-12 18:01 +0000
          Re: [Python-de] Datetime frage Arnold Krille <arnold@arnoldarts.de> - 2016-12-12 21:04 +0100
      Re: [Python-de] Datetime frage Achim Herwig <python@wodca.de> - 2016-12-11 21:03 +0100
        Re: [Python-de] Datetime frage Manfred Gil <manfred-gil@t-online.de> - 2016-12-12 18:04 +0000
          Re: [Python-de] Datetime frage Achim Herwig <python@wodca.de> - 2016-12-12 20:50 +0100
  Re: [Python-de] Datetime frage Hans-Peter Jansen <hpj@urpla.net> - 2016-12-11 21:01 +0100
    Re: [Python-de] Datetime frage Manfred Gil <manfred-gil@t-online.de> - 2016-12-12 18:07 +0000
      Re: [Python-de] Datetime frage Hans-Peter Jansen <hpj@urpla.net> - 2016-12-12 21:42 +0100
        Re: [Python-de] Datetime frage Manfred Gil <manfred-gil@t-online.de> - 2016-12-13 17:38 +0000
          Re: [Python-de] Datetime frage Hans-Peter Jansen <hpj@urpla.net> - 2016-12-13 20:46 +0100

csiph-web