ํฐ์คํ ๋ฆฌ ๋ทฐ
๐ ์ธ์คํด์ค์ ์ถ๋ ฅํ์์ ์ง์ ํ๋ ๋ฐฉ๋ฒ
1. print๋ฌธ ์์์ format ์ง์
class Coord(object):
def __init__ (self, x, y):
self.x, self.y = x, y
point = Coord(1, 2)
print( '({}, {})'.format(point.x, point.y) )
2. ํด๋์ค ๋ฐ๊นฅ์ ์ถ๋ ฅ ํจ์ ์์ฑ
class Coord(object):
def __init__ (self, x, y):
self.x, self.y = x, y
def print_coord(coord):
print( '({}, {})'.format(coord.x, coord.y) )
print_coord(point)
3. __str__ ๋ฉ์๋๋ฅผ ์ฌ์ฉํ์ฌ ํด๋์ค ๋ด๋ถ์์ ์ถ๋ ฅ format ์ง์
class Coord(object):
def __init__ (self, x, y):
self.x, self.y = x, y
def __str__ (self):
return '({}, {})'.format(self.x, self.y)
point = Coord(1, 2)
ํ๋ก๊ทธ๋๋จธ์ค - ํ์ด์ฌ์ ํ์ด์ฌ๋ต๊ฒ ๊ฐ์๋ฅผ ๋ฃ๊ณ ์ ๋ฆฌํ ๋ด์ฉ
programmers.co.kr/learn/courses/4008
'python' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
| python - ํ์ผ ์ ์ถ๋ ฅ ๊ฐ๋จํ๊ฒ ํ๊ธฐ(with-as) (0) | 2021.04.03 |
|---|---|
| python inf (0) | 2021.04.03 |
| python - binary search(์ด์ง ํ์) (0) | 2021.04.03 |
| python - swap (0) | 2021.04.03 |
| flag or for-else (0) | 2021.04.03 |
๋๊ธ
๊ณต์ง์ฌํญ
์ต๊ทผ์ ์ฌ๋ผ์จ ๊ธ
์ต๊ทผ์ ๋ฌ๋ฆฐ ๋๊ธ
- Total
- Today
- Yesterday
๋งํฌ
TAG
- ์คํ๋ง๋ถํธ
- ์๋ฃ๊ตฌ์กฐ
- airbnb clone
- ์ง์ ์ฃผ์
- tailwind
- divmod
- ํ์ด์ฌ
- ์๋ฐฉํฅ ์ฐ๊ฒฐ ๋ฆฌ์คํธ
- ์ ํ ๋ฐฐ์ด
- ์ ํ ํ์
- rjust
- ljust
- postfix notation
- initBinder
- sequence type
- ์ด์ง ํ์
- python
- springboot
- most_common
- Stack
- string module
- ValidataionUtils
- valid annotation
- for-else
- djnago
- ์์กด ์ฃผ์
- ์คํ
- ์ถ๋ ฅ ํ์ ์ง์
- Django
- python flag
| ์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
|---|---|---|---|---|---|---|
| 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 |
๊ธ ๋ณด๊ดํจ
