Lesson 1 - Python3 f-Strings - A better way to format strings

Опубликовано: 16 Декабрь 2019
на канале: Django Lessons
647
10

Python supports multiple ways to format text strings. These include %-formatting , str.format(). Each of these methods have their advantages, but in addition have disadvantages that make them cumbersome to use in practice. Since python 3.6 a new way of formatting was introduced: "f-strings".

Example:
logger.debug(f"Lesson title = {self.title}")
Notice little "f" before the string.
References:
https://www.python.org/dev/peps/pep-0...
https://github.com/ciur/lesson-1-f-st...