The Python Oracle

String formatting: % vs. .format vs. f-string literal

Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: Mysterious Puzzle

--

Chapters
00:00 Question
01:11 Accepted answer (Score 981)
02:43 Answer 2 (Score 317)
03:49 Answer 3 (Score 156)
04:15 Answer 4 (Score 132)
04:46 Thank you

--

Full question
https://stackoverflow.com/questions/5082...

Question links:
[str.format]: https://docs.python.org/2/library/stdtyp...
[How do I put a variable’s value inside a string?]: https://stackoverflow.com/questions/2960...

Answer 3 links:
[f-strings]: https://docs.python.org/3.6/whatsnew/3.6...
https://docs.python.org/3.6/reference/le...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #performance #stringformatting #fstring

#avk47