Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Link: http://stackoverflow.com/questions/5082452/python-string-formatting-vs-format
- #!/usr/bin/python
- sub1 = "python string!"
- sub2 = "an arg"
- a = "i am a %s" % sub1
- b = "i am a {0}".format(sub1)
- c = "with %(kwarg)s!" % {'kwarg':sub2}
- d = "with {kwarg}!".format(kwarg=sub2)
- print a # "i am a python string!"
- print b # "i am a python string!"
- print c # "with an arg!"
- print d # "with an arg!"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement