원문 : http://learnpythonthehardway.org/book/ex8.html
또 프린트...(ex8.py)
formatter = "%r %r %r %r"
print formatter % (1, 2, 3, 4)
print formatter % ("one", "two", "three", "four")
print formatter % (True, False, False, True)
print formatter % (formatter, formatter, formatter, formatter)
print formatter % (
"I had this thing.",
"That you could type up right.",
"But it didn't sing.",
"So I said goodnight."
)
결과
알 수 있는 내용...
1. "%r" 은 python interpreter가 이해하는 모양새(repr() 함수의 결과)로 표시된다. (디버깅 할때 좋다.)
2. python 을 작성할때 코드가 길어지면 여러 줄로 작성해도 된다.
반응형
'Python > Python 어렵게 배우기' 카테고리의 다른 글
| Python 어렵게 배우기 - Exercise 10: What Was That? (0) | 2013.11.28 |
|---|---|
| Python 어렵게 배우기 - Exercise 9: Printing, Printing, Printing (0) | 2013.11.21 |
| Python 어렵게 배우기 - Exercise 7: More Printing (0) | 2013.11.21 |
| Python 어렵게 배우기 - Exercise 6: Strings and Text (0) | 2013.11.20 |
| Python 어렵게 배우기 - Exercise 5: More Variables and Printing (0) | 2013.11.20 |