好词典

repr

UK /rɪˈpr/US /rɪˈpr/

词源

缩写自 Python 的 repr() 函数,源自 'representation'(表示)。

noun

❶ repr 是 Python 中 repr() 函数的缩写,用于获取对象的官方字符串表示形式,通常用于调试和开发。

“print(repr('hello'))”

(打印字符串 'hello' 的官方表示形式。)

“The repr of a list shows its elements clearly.”

(列表的 repr 会清晰地显示其元素。)

同义词:representation, string representation, official string

常见短语

__repr__ — Python 中的魔术方法,用于定义对象的官方字符串表示形式,通常用于调试。

“def __repr__(self): return 'MyClass()'”

(定义 __repr__ 方法返回对象的官方表示。)