python built-in function study-----repr
来源:互联网 发布:sql sum 不用group by 编辑:程序博客网 时间:2024/06/01 22:48
repr
(object)Return a string containing a printable representation of an object. For many types, this function makes an attempt to return a string that would yield an object with the same value when passed to eval()
, otherwise the representation is a string enclosed in angle brackets that contains the name of the type of the object together with additional information often including the name and address of the object. A class can control what this function returns for its instances by defining a __repr__()
method.
>>> help(repr)Help on built-in function repr in module builtins:repr(...) repr(object) -> string Return the canonical string representation of the object. For most object types, eval(repr(object)) == object.example:
>>> class Pair():def __init__(self,x,y):self.x=xself.y=ydef __repr__(self):return('Pair({0.x!r},{0.y!r}'.format(self))def __str__(self):return('{0.x!s},{0.y!s}'.format(self))>>> p=Pair(3,4)>>> pPair(3,4
特殊方法__repr__()返回的是实例的代码表示(code representation)
0 0
- python built-in function study-----repr
- Python built-in types - repr(object)
- python built-in function summary
- Python内置函数(built-in function)
- Python built-in function - abs(x)
- Python built-in function - all(iterable)
- Python built-in function - any(iterable)
- Python built-in function - ascii(object)
- Python built-in function - bin(x)
- Python built-in function - bool([x])
- built-in function
- PeopleCode built-in function
- built-in function
- the built-in function of range() in python
- the built-in function of eval() in python
- the built-in function of reduce in python
- Python built-in function - bytearray([source[, encoding[, errors]]])
- The study of parameter of function in Python(20170908)
- git命令
- Jedis 解决连接Redis Cluster不支持密码的问题
- 人在当时处境中,像旋涡中的一片落叶,身不由己
- get/post方式调用http接口
- 支持手势缩放的ImageView
- python built-in function study-----repr
- Android开发之Coding.net代码托管架构
- 解决windows gitk显示中文乱码问题
- 开发你自己的Android 授权管理器 (AccountManager的使用以及应用场景)
- BOM
- PHP与MySql数据库连接
- 美国最适合科技工作者生活的十佳城市
- 欢迎使用CSDN-markdown编辑器
- C# 多元一次方程算法,高斯消元列主消元法比较