파이썬[Python]: textwrap - TextWrapper 클래스
textwrap 모듈 - TextWrapper 클래스(class)
/// 설명
text를 표현하는데 있어 편리한 도구를 제공하는 객체입니다.
※ 형식
class textwrap.TextWrapper(**kwargs)
reference
https://docs.python.org/release/3.10.0/library/textwrap.html#module-textwrap
※ 형식
class textwrap.TextWrapper(**kwargs)
reference
https://docs.python.org/release/3.10.0/library/textwrap.html#module-textwrap
/// 예제
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | from textwrap import * test_str = '''The textwrap module provides some convenience functions, as well as TextWrapper, the class that does all the work. If you’re just wrapping or filling one or two text strings, the convenience functions should be good enough; otherwise, you should use an instance of TextWrapper for efficiency. ''' test_tw = TextWrapper() test_text = test_tw.wrap(test_str) for i in test_text: print(i) # The textwrap module provides some convenience functions, as well as # TextWrapper, the class that does all the work. If you’re just # wrapping or filling one or two text strings, the convenience # functions should be good enough; otherwise, you should use an # instance of TextWrapper for efficiency. print() test_tw.initial_indent = ' ' test_text = test_tw.wrap(test_str) for i in test_text: print(i) # The textwrap module provides some convenience functions, as well as # TextWrapper, the class that does all the work. If you’re just # wrapping or filling one or two text strings, the convenience # functions should be good enough; otherwise, you should use an # instance of TextWrapper for efficiency. | cs |
* 실행환경: Microsoft Windows 10 Homes
* 인터프리터: 파이썬(Python 3.9)
– 당신을 응원합니다. –
댓글
댓글 쓰기