Created
February 7, 2013 21:27
-
-
Save lambdamusic/4734370 to your computer and use it in GitHub Desktop.
Python: Python: formatting strings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>>list = ["Brad", "Dayley", "Python Phrasebook", | |
2006] | |
>>>letter = """ | |
>>>Dear Mr. %s,\n | |
>>>Thank you for your %s book submission. | |
>>>You should be hearing from us in %d.""" | |
>>>display = """ | |
>>>Title: %s | |
>>>Author: %s, %s | |
>>>Date: %d""" | |
>>>record = "%s|%s|%s|%08d" | |
>>>print letter % (list[1], list[2], list[3]) | |
Dear Mr. Dayley, | |
Thank you for your Python Phrasebook book submission. | |
You should be hearing from us in 2006. | |
>>>print display % (list[2], list[1], list[0], | |
list[3]) | |
Title: Python Phrasebook | |
Author: Dayley, Brad | |
Date: 2006 | |
>>>print record % (list[0], list[1], list[2], | |
list[3]) | |
Brad|Dayley|Python Phrasebook|00002006 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment