[Tutor] Formatting a string
Becky Mcquilling
ladymcse2000 at gmail.com
Tue Feb 1 18:45:10 CET 2011
Thanks, as always. It all works.
Becky
On Tue, Feb 1, 2011 at 7:08 AM, Alan Gauld <alan.gauld at btinternet.com>wrote:
> "Becky Mcquilling" <ladymcse2000 at gmail.com> wrote
>
>
> Basically, I need to format a string as an example:
>>
>> "He is {what}.format("{wild}")
>>
>> I want to insert wild in place of what and output the resulting text WITH
>> the curly braces.
>>
>
> what = 'wild'
>>>> "Here is {what}".format(what=what)
>>>>
>>> 'Here is wild'
>
>> "Here is {what}".format(what='wild')
>>>>
>>> 'Here is wild'
>
>> "Here is {{what}}".format(what='wild')
>>>>
>>> 'Here is {what}'
>
>> "Here is {what}".format(what='{wild}')
>>>>
>>> 'Here is {wild}'
>
>>
>>>>
> Take your pick :-)
>
> --
> Alan Gauld
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
>
>
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110201/e5e33266/attachment.html>
More information about the Tutor
mailing list