TIL: f-strings support = for quick debugging in Python 3.8+
When debugging Python code, it's often useful to print out the values of variables. In Python 3.8 and later, f-strings have a convenient feature that allows you to do this quickly and easily. You can use the = symbol after a variable name in an f-string to print both the name and the value of the variable.
Before:
x = 5
print(f"x: {x}")
This will output: x: 5
After:
x = 5
print(f"{x=}")
This will output: x=5
Follow me on Dev.to for daily Python tips and quick guides!
喜欢这篇文章?关注获取更多Python自动化内容!
If you found this useful, you might like Python Automation Scripts Pack (10 Ready-to-Use Tools) — a practical resource that takes things a step further. At $14.99 it's a solid investment for your toolkit.
Top comments (0)