-
[python] string formaterPrograming/Python 2019. 4. 8. 15:46
PyFormat: Using % and .format() for great good!
Python has had awesome string formatters for many years but the documentation on them is far too theoretic and technical. With this site we try to show you the most common use-cases covered by the old and new style string formatting API with practical exam
pyformat.info
input
2 output
1 1 1 1
2 2 2 10
123456789def print_formatted(number):# your code goes herewidth = len("{0:b}".format(number))for i in range(1, number+1):print("{0:{length}d} {0:{length}o} {0:{length}X} {0:{length}b}".format(i, length=width))if __name__ == '__main__':n = int(input())print_formatted(n)cs 'Programing > Python' 카테고리의 다른 글
[django] admin page를 통해 DB data 생성 (0) 2019.04.09 [django] DB 생성과 마이그레이션 (0) 2019.04.09 [Django] 서버주소 0.0.0.0 (0) 2019.04.08 [Django] Invalid HTTP_HOST header:, You may need to add 'x.x.x.x' to ALLOWED_HOSTS (0) 2019.04.08 Emulating numeric types (0) 2019.03.29