By: Zed A. Shaw Viewed: 1399 times Printer Friendly Format
Printing and formatting the printing is done quite often in any program. This simple python script just shows different ways of printing text and characters in python.
1 formatter = "%r %r %r %r"
3 print formatter % (1, 2, 3, 4)
4 print formatter % ("one", "two", "three", "four")
5 print formatter % (True, False, False, True)
6 print formatter % (formatter, formatter, formatter, formatter)
7 print formatter % (
8 "I had this thing.",
9 "That you could type up right.",
10 "But it didn't sing.",
11 "So I said goodnight."
What You Should See
$ python ex8.py
1 2 3 4
'one' 'two' 'three' 'four'
True False False True
'%r %r %r %r' '%r %r %r %r' '%r %r %r %r' '%r %r %r %r'
'I had this thing.' 'That you could type up right.' "But it didn't sing." 'So I said goodnight.'
Most Viewed Articles (in python )
Latest Articles (in python)
Comment on this tutorial
- Cloud Computing
- Java Beans
- Mac OS X
- Office 365
- Tech Reviews