repr() in python
#The repr() function returns a printable representation of the given object.
#repr() takes a single object.
#Syntax
val = "string"
print(repr(val)) #output ---->"'string'"
repr() in python
#The repr() function returns a printable representation of the given object.
#repr() takes a single object.
#Syntax
val = "string"
print(repr(val)) #output ---->"'string'"
python repr
# The repr() function returns a printable representational string of the given object.
>>> var = 'foo'
>>> print(repr(var))
"'foo'"
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()
# Prints readable format for date-time object
print (str(today))
# prints the official format of date-time object
print (repr(today))
Output:
2016-02-22 19:32:04.078030
datetime.datetime(2016, 2, 22, 19, 32, 4, 78030)
From: geeksforgeeks.org
what is repr function in python
#The repr() function returns a printable representation of the given object.
Upvote = "Do make an upvote click on the top right corner button."
>>> print(Upvote)
>>> 'Do make an upvote click on the top right corner button.'
>>> print(repr(Upvote))
>>>"'Do make an upvote click on the top right corner button.'"
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us