Monday, 3 October 2022

f string / Format String in Python

Python f-string is the newest Python syntax to do string formatting. It is available since Python 3.6. Python f-strings provide a faster, more readable, more concise, and less error prone way of formatting strings in Python.

The f-strings have the f prefix and use {} brackets to evaluate values.


For example :

val = "intheworldperfecfull"
print(f'{val} test')

The output :

intheworldperfecfull test


Source : https://zetcode.com/python/fstring/

No comments:

Post a Comment