3 ms·
This can also be achieved using '%': your_dict = { "some": "awesome", "from": "out of", "dictionary": "mapping", } "insert %(some)s values %(
by CrLf 6y ago
This can also be achieved using '%':
your_dict = {
"some": "awesome",
"from": "out of",
"dictionary": "mapping",
}
"insert %(some)s values %(from)s a %(dictionary)s" % your_dict
WRT .format, '%' is safer to use with untrusted (well, semi-trusted) format strings, whereas .format can lead to code injection (in more insidious ways than with f-strings).