- 기준 소스코드 표현 방식

>>> # string과 비교
>>> str = 'Here is a \n newline! '
>>> print(str)
	Here is a 
	 newline! 
>>> print(repr(str))
	'Here is a \n newline! '
>>> 
>>> # format 메서드 표현
>>> print('{}'.format(str))
	Here is a 
	 newline! 
>>> print('{!r}'.format(str))
	'Here is a \n newline! '
>>> 
>>> # 색인숫자와 같이 사용
>>> print('{1!r} loves {0!r}'.format('Joanie', 'ChaCha'))
	'ChaCha' loves 'Joanie'

'Python > 공통이론' 카테고리의 다른 글

Python - 정규표현식  (0) 2023.04.25
Python - format 함수&메서드의 사양 필드  (0) 2023.04.17
Python - format 메서드  (0) 2023.04.14
Python - format 함수  (0) 2023.04.14
Python - 텍스트 포맷팅  (0) 2023.04.13

+ Recent posts