[Tutor] Question about formating string with dictionary
Shuai Jiang (Runiteking1)
marshall.jiang at gmail.com
Fri Apr 27 03:23:59 CEST 2007
Hello everyone,
The program that I am working on right now have a template for string
formatting.
My question is that is it possible to use multiple dictionary to format the
string.
For example
x = {'foo':1234, 'bar': 5678}
y = {'spam':'hello','cheese':'good-bye'}
is there any way to use his pseudo code
template = \
"""Foo = %(foo)s
bar = %(bar)s
spame = %(spam)s
cheese = %(cheese)s"""
print template %x,y
Thanks
Marshall
--
I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as
equals.
Sir Winston Churchill
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070426/93ae00b3/attachment.html
More information about the Tutor
mailing list