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


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

Re: [Python-de] { als Zeichen in Format

From Peter Otten <__peter__@web.de>
Newsgroups de.comp.lang.python
Subject Re: [Python-de] { als Zeichen in Format
Date 2017-07-03 14:04 +0200
Organization None
Message-ID <mailman.27.1499083512.2926.python-de@python.org> (permalink)
References <eruls4Fp2pU1@mid.individual.net> <b90b0520-9c06-5658-de70-8d603a437529@sschwarzer.net> <ojdbt2$mn9$2@blaine.gmane.org>

Show all headers | View raw


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 }}.
"""

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


Thread

{ als Zeichen in Format Hermann Riemann <nospam.ng@hermann-riemann.de> - 2017-07-03 12:50 +0200
  Re: [Python-de] { als Zeichen in Format Stefan Schwarzer <sschwarzer@sschwarzer.net> - 2017-07-03 13:21 +0200
    Re: [Python-de] { als Zeichen in Format Hermann Riemann <nospam.ng@hermann-riemann.de> - 2017-07-03 15:07 +0200
  Re: [Python-de] { als Zeichen in Format Peter Otten <__peter__@web.de> - 2017-07-03 13:59 +0200
  Re: [Python-de] { als Zeichen in Format Peter Otten <__peter__@web.de> - 2017-07-03 14:04 +0200
    Re: [Python-de] { als Zeichen in Format Hermann Riemann <nospam.ng@hermann-riemann.de> - 2017-07-03 15:34 +0200

csiph-web