fosshelp
Custom Search
Sunday, April 17, 2011
python Named string formatting example
python Named string formatting example
my_dict = {'foo': 'answer', 'bar':42}
print "The %(foo)s is %(bar)i." % my_dict
#New Style Formatting
print("The {foo} is {bar}".format(foo='answer', bar=42))
OUTPUT
=======
The answer is 42.
The answer is 42
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment