Format string with single quotes in it

Xavier Ho contact at xavierho.com
Fri Sep 25 09:02:30 EDT 2009


On Fri, Sep 25, 2009 at 10:42 PM, Bahadir <bilgehan.balban at gmail.com> wrote:

> Hi there,
>
> My question is simple, but I've been spending some hours over the web
> and still struggling to get this right: How do I format a string that
> contains single quotes in it?
>

I don't know what you're doing wrong, but I've tried both Python 2.6.2 and
3.1.1, and the following worked perfectly for me:

>>> a = "Mrra%d 'Mrraa!!%d'"
>>> a %(1,2)
"Mrra1 'Mrraa!!2'"

Maybe if you share a snippet of the code, or do more actual testing that
might help?

Good luck,
Xav
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090925/9ec414c3/attachment-0001.html>


More information about the Python-list mailing list