상세 컨텐츠

본문 제목

String Width and Precision

Python

by techbard 2016. 6. 4. 00:27

본문

반응형

# 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' % 42

# print(priceOfHam)



# s = '%s plus %s equals %s' %(1, 1, 2)


# print(s)




# p = "Pi with three decimal: %0.3f"


# from math import pi

# print(p % pi)



반응형

관련글 더보기

댓글 영역