Python: f-String (Format, Template)

By Xah Lee. Date: .

F Prefix String

f in front of the string quote means the string can embed variable and expressions, via the syntax {}.

new in python 3.6 (year 2016)

# f-string
x = 3
y = f"i have {x} cats"
print(y)
# "i have 3 cats"

the format code syntax is same as

Python, format string

Python, String