Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >>> r'hello"world'
- 'hello\"world'
- >>> print(r'hello"world')
- hello"world
- class My:
- def __str__(self):
- return '__str__: Вызывается для print'
- def __repr__(self):
- return '__repr__: Вызывается в интерактивном режиме'
- obj = My()
- print(obj)
- >>> obj
- __repr__: Вызывается в интерактивном режиме
- >>> a = r'hello"world'
- >>> a #равносильно вызову print(a.__repr__())
- 'hello\"world'
- >>> print(a) #равносильно вызову print(a.__str__())
- hello"world
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement