Python repr() 函数
本帖最后由 一个账号 于 2020-3-20 14:53 编辑Python repr() 函数
语法
repr(obj, /)
参数
参数描述
obj对象
描述
与 Python ascii() 函数 类似。
返回值
字符串。
例子
>>> repr("你好")
"'你好'"
>>> repr(123)
'123'
>>> repr(BaseException)
"<class 'BaseException'>"
>>> repr(object)
"<class 'object'>"
>>> repr(repr(repr))
"'<built-in function repr>'"
>>> def test():
pass
>>> class A:
def __repr__(self):
return "class A"
>>> a = A()
>>> repr(a)
'class A'
>>>
页:
[1]