Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Peter Otten <__peter__@web.de> Newsgroups: de.comp.lang.python Subject: Re: [Python-de] { als Zeichen in Format Date: Mon, 03 Jul 2017 14:04:56 +0200 Organization: None Lines: 24 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit X-Trace: news.uni-berlin.de EaTKWLFMGwd0ez1Sbk7aEQIhCdS1bMBkA/RspZdtiplA== Return-Path: X-Original-To: python-de@python.org Delivered-To: python-de@mail.python.org X-Injected-Via-Gmane: http://gmane.org/ User-Agent: KNode/4.13.3 X-BeenThere: python-de@python.org X-Mailman-Version: 2.1.24 Precedence: list List-Id: Die Deutsche Python Mailingliste List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: Xref: csiph.com de.comp.lang.python:4842 Stefan Schwarzer wrote: > On 2017-07-03 12:50, Hermann Riemann wrote: >> computed_len=zahl=4 # Testzeile für Beispiel >> s="{:%d}"%computed_len >> print(s.format(zahl)) # Testzeile für Beispiel >> >> Wie setze ich die Zeile mit s= nach format um? > > Meinst du sowas: > >>>> "{{:{}d}}".format(5) > '{:5d}' > > Ich habe das jetzt auf die Schnelle aber auch nicht in der Doku gefunden, > sondern hatte eine vage Erinnerung, dass ich da mal was gelesen hatte. https://docs.python.org/dev/library/string.html#format-string-syntax """ If you need to include a brace character in the literal text, it can be escaped by doubling: {{ and }}. """