Quantcast
Viewing all articles
Browse latest Browse all 4723

Need to double escape single quotes in str fetch?

I wantd to store the string 'self' in a variable, which is later used in setting a header.

My first attempts all resulted in just self (note the absense of the single quotes:

str("'self'")
str(\'self\')
str("\'self\'")

And if I try

str(\\'self\\')

it results in \self\.

Eventually I got it to work with str("\\'str\\'").

Why do I need to double escape the single quotes inside of double quotes? I wasn’t able to find any documentation that explains that.

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 4723

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>