3개의 단일인용부호 안에 여러 줄이 있는 경우, 문자열 끝에 들어 있는 라인 끝 문자는 보존된다. 그리고 양쪽 끝에 공백이 있는 경우에도 보존된다.
>>> blake = '''In seed time learn, in harvest teach, in winter enjoy.
... Drive your cart and your plow over the bones of the dead.
... The road of excess leads to the palace of wisdom.
... Prudence is a rich ugly old maid courted by Incapacity.
... He who desires but acts not, breeds pestilence.
... The cut worm forgives the plow.
... Dip him in the river who loves water.
... A fool sees not the same tree that a wise man sees.
... He whose face gives no light, shall never become a star.
... Eternity is in love with the productions of time.
... The busy bee has no time for sorrow.
... The hours of folly are measur'd by the clock, but of wisdom: no clock can measure.
... All wholsom food is caught without a net or a trap.
... Bring out number weight & measure in a year of dearth.
... No bird soars too high, if he soars with his own wings.
... A dead body, revenges not injuries.
... The most sublime act is to set another before you.
... If the fool would persist in his folly he would become wise.
... Folly is the cloke of knavery.
... Shame is Prides cloke.
... '''
대화식 인터프리터 출력 결과 - 단일 인용부호 또는 \n 과 같은 escape character 가 들어있는 문자열 출력 가능
>>> blake
"In seed time learn, in harvest teach, in winter enjoy.\n Drive your cart and your plow over the bones of the dead.\nThe road of excess leads to the palace of wisdom.\nPrudence is a rich ugly old maid courted by Incapacity.\nHe who desires but acts not, breeds pestilence.\nThe cut worm forgives the plow.\n Dip him in the river who loves water.\nA fool sees not the same tree that a wise man sees. \nHe whose face gives no light, shall never become a star.\nEternity is in love with the productions of time.\nThe busy bee has no time for sorrow.\nThe hours of folly are measur'd by the clock, but of wis\xaddom: no clock can measure.\nAll wholsom food is caught without a net or a trap.\nBring out number weight & measure in a year of dearth.\nNo bird soars too high, if he soars with his own wings.\nA dead body, revenges not injuries.\nThe most sublime act is to set another before you.\nIf the fool would persist in his folly he would become wise.\nFolly is the cloke of knavery.\nShame is Prides cloke.\n"
>>>
print() 출력 결과
인용부호를 제거한 뒤 내용 출력한다.
출력할 것들 사이의 공백과 줄바꿈을 유용하게 추가 가능하다.
>>> print(blake)
In seed time learn, in harvest teach, in winter enjoy.
Drive your cart and your plow over the bones of the dead.
The road of excess leads to the palace of wisdom.
Prudence is a rich ugly old maid courted by Incapacity.
He who desires but acts not, breeds pestilence.
The cut worm forgives the plow.
Dip him in the river who loves water.
A fool sees not the same tree that a wise man sees.
He whose face gives no light, shall never become a star.
Eternity isin love with the productions of time.
The busy bee has no time for sorrow.
The hours of folly are measured by the clock, but of wisdom: no clock can measure.
All wholsom food is caught without a net or a trap.
Bring out number weight & measure in a year of dearth.
No bird soars too high, if he soars with his own wings.
A dead body, revenges not injuries.
The most sublime act is to set another before you.
If the fool would persist in his folly he would become wise.
Folly is the cloke of knavery.
Shame is Prides cloke.
빈문자열 생성 - 여러 문자열을 한 문자열로 합칠 때 문자열 사이에 공백을 입력할 때 유용
>>> ''
''
>>> ""
''
>>> ''''''
''
>>> """"""
''
>>>
데이터 타입 변환
str() 함수를 이용하여 데이터 타입을 문자열로 변환가능
문자열이 아닌 객체를 print() 로 호출할 때, 파이썬은 내부적으로 str() 함수를 사용함
댓글을 사용할 수 없습니다.