Old format with %
Hello It seems that caracter % can't be escaped >>>"test %d %" % 7 ValueError: incomplete format >>>"test %d \%" % 7 ValueError: incomplete format >>>"test %d" % 7 + "%" 'test 7%' # OK But is there a way to escape a % ? thx -- https://mail.python.org/mailman/listinfo/python-list
Re: Old format with %
Le 14/02/2018 à 13:46, ast a écrit : Hello It seems that caracter % can't be escaped >>>"test %d %" % 7 ValueError: incomplete format >>>"test %d \%" % 7 ValueError: incomplete format >>>"test %d" % 7 + "%" 'test 7%' # OK But is there a way to escape a % ? thx Found, double % to escape it >>>"test %d%%" % 7 'test 7%' -- https://mail.python.org/mailman/listinfo/python-list
Re: Old format with %
On 2/14/2018 7:54 AM, ast wrote: Le 14/02/2018 à 13:46, ast a écrit : Hello It seems that caracter % can't be escaped >>>"test %d %" % 7 ValueError: incomplete format >>>"test %d \%" % 7 ValueError: incomplete format >>>"test %d" % 7 + "%" 'test 7%' # OK But is there a way to escape a % ? thx Found, double % to escape it >>>"test %d%%" % 7 'test 7%' Same with { and } in new format and f strings. >>> a = 3 >>> f'{{x:{a}}}' '{x:3}' -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Old format with %
It can be escaped: "test %d %%" % 7 Terry Reedy schrieb am Mi., 14. Feb. 2018 um 20:53 Uhr: > On 2/14/2018 7:54 AM, ast wrote: > > Le 14/02/2018 à 13:46, ast a écrit : > >> Hello > >> > >> It seems that caracter % can't be escaped > >> > >> >>>"test %d %" % 7 > >> ValueError: incomplete format > >> > >> >>>"test %d \%" % 7 > >> ValueError: incomplete format > >> > >> >>>"test %d" % 7 + "%" > >> 'test 7%' # OK > >> > >> But is there a way to escape a % ? > >> > >> thx > > > > Found, double % to escape it > > > > >>>"test %d%%" % 7 > > 'test 7%' > > Same with { and } in new format and f strings. > >>> a = 3 > >>> f'{{x:{a}}}' > '{x:3}' > > -- > Terry Jan Reedy > > > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list