[Tutor] Escaping a single quote mark in a triple quoted string.
Ray Parrish
crp at cmc.net
Sat Mar 13 18:33:57 CET 2010
Hello,
I am getting the following -
>>> String = """<a href="http://www.rayslinks.com">Ray's Links</a>"""
>>> String
'<a href="http://www.rayslinks.com">Ray\'s Links</a>'
Note the magically appearing back slash in my result string. Now I tiry
to escape the single quote.
>>> String = """<a href="http://www.rayslinks.com">Ray\'s Links</a>"""
>>> String
'<a href="http://www.rayslinks.com">Ray\'s Links</a>'
Once again the unwanted back slash appears.
>>> NewString = """'"""
>>> NewString
"'"
Hmmm, no back slash this time...
>>> String = """<a href="http://www.rayslinks.com">Ray""" + """'""" +
"""s Links</a>"""
>>> String
'<a href="http://www.rayslinks.com">Ray\'s Links</a>'
Why did quoting the single quote work in NewString when I triple quoted
just the single quote, but not in the other examples where the result
shows a back slash before my singe quote in String?
Is there a proper way to do this?
Thanks, Ray Parrish
--
Linux dpkg Software Report script set..
http://www.rayslinks.com/LinuxdpkgSoftwareReport.html
Ray's Links, a variety of links to usefull things, and articles by Ray.
http://www.rayslinks.com
Writings of "The" Schizophrenic, what it's like to be a schizo, and other
things, including my poetry.
http://www.writingsoftheschizophrenic.com
More information about the Tutor
mailing list