__ repr _ _ v Pythonu

Příklady kódu

6
0

python repr

# The repr() function returns a printable representational string of the given object.
>>> var = 'foo'
>>> print(repr(var))
"'foo'"
2
0

__ Repre _ _ nebo _ _ 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
1
0

__ repr _ _ v Pythonu

    def __repr__(self) -> str:
        return
1
0

python__ repr _ _ význam

>>>x=4
>>>repr(x)
'4'
>>>str(x)
'4'
>>>y='stringy'
>>>repr(y)
"'stringy'"
>>>str(y)
'stringy'
1
0

krajta _ _ 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)'

V jiných jazycích

Tato stránka je v jiných jazycích

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