DEV Community

niuniu
niuniu

Posted on

Quick Tip: Python f-strings Tricks

Quick Tip

Python f-string tricks:

name = "World"
print(f"Hello, {name}!")
pi = 3.14159
print(f"Pi: {pi:.2f}")
print(f"{'hello':>10}")
x = 42
print(f"{x = }")
Enter fullscreen mode Exit fullscreen mode

Try with MonkeyCode!

python #coding #tips

Top comments (0)