python repel code example
Example 1: python repr
>>> var = 'foo'
>>> print(repr(var))
"'foo'"
Example 2: repr python
"""str() is used for creating output for end user while repr() is mainly used for debugging and development.
repr’s goal is to be unambiguous and str’s is to be readable.
For example, if we suspect a float has a small rounding error, repr will show us while str may not."""
import datetime
today = datetime.datetime.now()
print (str(today))
print (repr(today))
Output:
2016-02-22 19:32:04.078030
datetime.datetime(2016, 2, 22, 19, 32, 4, 78030)
From: geeksforgeeks.org