__str__와__repr 의 차이점__

코드 예제

2
0

__repr__또는__str__

very briefly
 - The default implementation is useless (it’s hard to think of one which wouldn’t be, but yeah)
 - __repr__ goal is to be unambiguous
 - __str__ goal is to be readable
 - Container’s __str__ uses contained objects’ __repr__
 
see source for more info
0
0

__str__와__repr 의 차이점__

>>> import datetime
>>> now = datetime.datetime.now()
>>> now.__str__()
'2020-12-27 22:28:00.324317'
>>> now.__repr__()
'datetime.datetime(2020, 12, 27, 22, 28, 0, 324317)'

비슷한 페이지

예제가있는 유사한 페이지

다른 언어로

이 페이지는 다른 언어로되어 있습니다

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................