class 之 ___repr__
来源:互联网 发布:mac osx系统下载 编辑:程序博客网 时间:2024/05/21 07:13
When defining a new repr(), return a string value that uses the member variables of the class to display the 3D point properly. You can use the str() function to put these numbers in the proper string.
For advanced users: For more information on repr and other special methods see this Python documentation. Note the slight difference between the repr and str methods.
class Point3D (object): def __init__(self,x,y,z): self.x = x self.y = y self.z = z def __repr__(self): return "(%d, %d, %d)" %(self.x, self.y, self.z) ##这里自己会经常用错格式,需要注意my_point = Point3D (1,2,3)print my_point
0 0
- class 之 ___repr__
- C#之 StringBuilder Class
- class之位对齐
- JDBC之Class.forName()
- class VideoCapture之:: VideoCapture
- 温故而知新之@class
- Ruby之Class
- OCJP之inner class
- 设备驱动之class
- lua之class
- OC之【@class】
- 【如饥似渴】之《class》
- java之Class
- JQuery 之CLASS选择器
- iOS 之NSLocale Class
- lua之class
- OC之@class
- Qt Class之QTableWidget
- Unity3d Texture2D打包图集
- oracle表空间不足扩容的方法
- 【HDU】 1166 敌兵布阵
- skb-7
- JAVA 笔记(一)
- class 之 ___repr__
- hibernate环境搭建(Hello world 配置文件版)
- 公有云提到的各个合规compliance都是什么东西?
- 基本算法——第二单元 高精度和进制转换
- 欢迎使用CSDN-markdown编辑器
- 卡尔曼滤波算法简要
- opencv从入门到精通(5)——矩阵和图像操作函数列表
- JAVA 笔记(二)
- JAVA 笔记(三)