Python repr() Function

Python 内置函数Python Built-in Functions


Description

The repr() function converts an object into a form that the interpreter can read.

Syntax

The following is the syntax for the repr() method:

repr(object)

Parameters

  • object -- An object.

Return Value

Returns a string format of an object.


Example

The following shows an example of using the repr() method:

>>> s = 'EXAMPLE'
>>> repr(s)
"'EXAMPLE'"
>>> dict = {'example': 'example.com', 'google': 'google.com'};
>>> repr(dict)
"{'google': 'google.com', 'example': 'example.com'}"
>>>

Python 内置函数Python Built-in Functions

Other Extensions