How to put backslash escape sequence into an f-string
If you want to write something like:
"{}MESSAGE{}".format("\t"*15, "\t"*15)
but using f-strings, you hit the issue that you cannot have a backslash inside an f-string expression.
Instead you should assign the tab character to a variable and then use that:
tab = '\t' * 15
f"{tab}MESSAGE{tab}"
Via SO.
Leave a comment