String Width and Precision
# Width and Precision # d1 = '%5d' % -10# print(d1) # d2 = '%5d' % 10# print(d2) # dd = '%05d' % -10# print(dd) # s = '%.*s' % (3, 'apple')# print(s) # from math import pi # pp = '[%010.2f]' % pi# print(pp) # pp2 = '[%-10.2f]' % pi# print(pp2) # p = '[%9f]' % pi# print(p) # p = '[%5.2f]' % pi# print(p) # p = '[%.2f]' % pi# print(p) # p = '[%0.2f]' % pi# print(p) # priceOfHam = 'Price of ham: $%d..
Python
2016. 6. 4. 00:27