__str__ vs __repr__ In Python

Опубликовано: 07 Ноябрь 2020
на канале: Finxter
332
8

Article Link: https://blog.finxter.com/python-__str...

The key goal of _str_ and _repr_ is to return a string representation of a Python object. The way they represent the string object differentiates them.

str() & _str()_ return a printable/readable string representation of an object which is focused on the end-user.
repr() & _repr()_ return a string representation of an object that is a valid Python object, something you can pass to eval() or type into the Python shell without getting an error. Its major goal is to be unambiguous.

_______________________________________________________________________________________________

Do you want to thrive as a self-employed Python freelancer controlling your own time, income, and work schedule? Check out our Python freelancer resources:

Finxter Python Freelancer Course:
https://blog.finxter.com/become-pytho...

Finxter Python Freelancer Webinar:
https://blog.finxter.com/webinar-free...

Leaving the Rat Race with Python (Book):
https://blog.finxter.com/book-leaving...


На этой странице сайта вы можете посмотреть видео онлайн __str__ vs __repr__ In Python длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Finxter 07 Ноябрь 2020, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 332 раз и оно понравилось 8 зрителям. Приятного просмотра!