1# The repr() function returns a printable representational string of the given object.
2>>> var = 'foo'
3>>> print(repr(var))
4"'foo'"
1"""str() is used for creating output for end user while repr() is mainly used for debugging and development.
2repr’s goal is to be unambiguous and str’s is to be readable.
3For example, if we suspect a float has a small rounding error, repr will show us while str may not."""
4
5import datetime
6today = datetime.datetime.now()
7# Prints readable format for date-time object
8print (str(today))
9
10# prints the official format of date-time object
11print (repr(today))
12
13Output:
14
152016-02-22 19:32:04.078030
16datetime.datetime(2016, 2, 22, 19, 32, 4, 78030)
17
18From: geeksforgeeks.org