Mots clés : pythonstringformatstring-formattingcurly-bracespython
95
>>> x = " {{ Hello }} {0} " >>> print(x.format(42)) ' { Hello } 42 '
84
n = 42 print(f" {{Hello}} {n} ")
{Hello} 42
hello = "HELLO" print(f"{{{hello.lower()}}}")
{hello}
74
x = "{{ Hello }} {0}" print(x.format(42))
62
import json data = "1,2" mydict = {"all": "false", "selected": data} json.dumps(mydict)
'{{"all": false, "selected": "{}"}}'.format(data)