.format vs. %

Yaşar Arabacı yasar11732 at gmail.com
Sat Dec 31 13:34:01 EST 2011


What exactly do you mean by putting .format into a variable? You mean like  
this:

"{name} is very {adj}  
{gender}".format(name="sandy",adj="diligent",gender="female")

Sat, 31 Dec 2011 20:19:34 +0200 tarihinde davidfx <dgeorge29ca at gmail.com>  
şöyle yazmış:

> Hello everyone,
> I just have a quick question about .format and %r %s %d.
>
> Should we always be using .format() for formatting strings or %?
>
> Example a = 'apples'
>               print "I love {0}.".format(a)
>
> If I wanted to put .format into a variable, how would I do that.
>
> Thanks for your information in advance.
>
> David


-- 
Opera'nın e-posta istemcisi ile gönderildi: http://www.opera.com/mail



More information about the Python-list mailing list