how to print using the printf operator in python code example
Example 1: python text fromatting rows
table_data = [
['a', 'b', 'c'],
['aaaaaaaaaa', 'b', 'c'],
['a', 'bbbbbbbbbb', 'c']
]
for row in table_data:
print("{: >20} {: >20} {: >20}".format(*row))
Example 2: python format numeric output
for x in numbers:
print "{:10.4f}".format(x)
prints
23.2300
0.1233
1.0000
4.2230
9887.2000
Example 3: print python format
print('{} {}'.format(1, 2))