combine a raw and f string containing curly brackats in Python

246 views Asked by At

I'm trying to convert some mathematical equations to a Word (.docx) file using the code snippet below:

y = 5
cur_par.add_run(r"\frac{-e^{i/pi}}{y^n}$!").font.math = True

However I would like to replace the "y" with the variable y (=5). I could write fr"{y}" or r."{y}.format(y=y), but both will recognize the other curly brackets and assume they are variables as well, which isn't the case.

Any idea how I could combine a raw string containing {} with an f-string?

0

There are 0 answers