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


Groups > fr.comp.lang.python > #3434

Re: Débutant. Formatage de input. Python 3.8

Path csiph.com!usenet.pasdenom.info!news.izac.org!reader
From Benoit Izac <use.reply.to@INVALID.ADDRESS>
Newsgroups fr.comp.lang.python
Subject Re: Débutant. Formatage de input. Python 3.8
Date Sun, 03 Jan 2021 08:40:45 +0100
Message-ID <87sg7ieade.fsf@izac.org> (permalink)
References <rsrglk$fe4$1@gioia.aioe.org>
Reply-To benoit.izac@free.fr
Mime-Version 1.0
Content-Type text/plain; charset=iso-8859-1
Content-Transfer-Encoding 8bit
Injection-Info keg.izac.org; logging-data="30835"; mail-complaints-to="usenet@izac.org"
Xref csiph.com fr.comp.lang.python:3434

Show key headers only | View raw


Bonjour,

Le 03/01/2021 à 05:20, Dominique a écrit dans le message
<rsrglk$fe4$1@gioia.aioe.org> :

> Je crois me souvenir qu'il y a un formatage particulier d'input qui
> permet d'introduire des paramètre du style :
>
> input('Donnez la valeur n°{x}')
>
> Sachant que {x} est, par exemple, un élément de for x in range(1,10)

Oui, ça s'appelle les f-strings, ça a été introduit avec la version 3.6
de Python :

<https://docs.python.org/fr/3/tutorial/inputoutput.html#formatted-string-literals>

input(f'Donnez la valeur n°{x}')

NB : Ce n'est pas spécifique à input().
-- 
Benoit Izac

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


Thread

Débutant. Formatage de input. Python 3.8 Dominique <zzz@aol.com.invalid> - 2021-01-03 05:20 +0100
  Re: Débutant. Formatage de input. Python 3.8 Benoit Izac <use.reply.to@INVALID.ADDRESS> - 2021-01-03 08:40 +0100
    Re: Débutant. Formatage de input. Python 3.8 Dominique <zzz@aol.com.invalid> - 2021-01-03 11:44 +0100

csiph-web