[Tutor] Writing to CSV string containing quote and comma
Alan Gauld
alan.gauld at btinternet.com
Tue Dec 10 01:46:07 CET 2013
On 09/12/13 23:46, Steven D'Aprano wrote:
> Python has two different quote characters ' and " so you can use one for
> delimiters and the other inside the string:
And if you need both you can also use triple quotes.
> If you need both, you can escape the one that matches the delimiter:
>
> s = 'this string contains both \' single and " double quotes'
Or using triple quotes:
> s = '''this string contains both ' single and " double quotes'''
Python will then do the escaping for you.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list