Search code examples
pythonpython-3.xbackslash

How can I display a string with its rational expressions, such as '\'


I want to display a rational expression using Python 3. Because it is stored in my variable, it applies the effect of the backslash on my terminal, here is the rational expression I try to display :

struct = "{}\"{}\"{}{}{}"

So what I am trying to find is an expression that prints all the string, including the '\'


Solution

  • You can solve it like this:

    struct = '{}\\"{}\\"{}{}{}'