Format string with single quotes in it

Xavier Ho contact at
Fri Sep 25 15:02:30 CEST 2009

On Fri, Sep 25, 2009 at 10:42 PM, Bahadir <bilgehan.balban at> 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,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list