class 之 ___repr__
2016-01-26 15:10
204 查看
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.
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
相关文章推荐
- mybatis拦截器的执行顺序
- lvs中dr模式配置脚本
- Java RMI 远程方法调用
- C语言 文件操作4--文件结构体FILE的理解以及缓冲区再讲
- android Xutils Http模块分析
- java邮件(带附件发送)
- javascript 1: 变量 内存 作用域简单描述
- JBOSS启动报错Failed to start service jboss.web.deployment.default-host.
- 面试题
- skb-6
- Linux上编译opencv程序
- XSS攻击简介
- oracle表空间不足扩容的方法
- 使用xib方式创建UITableViewCell,设置Label自动换行注意事项
- java面向对象学习笔记
- Node.js 学习(五)Node.js 事件循环
- UIStatusBarStyle PreferredStatusBarStyle does not work
- Linux 最常用的操作命令
- Linux 最常用的操作命令
- Linux 最常用的操作命令