|
|
发表于 2017-7-29 12:35:37
|
显示全部楼层
本楼为最佳答案
内部方法就是只能从类内部调用的方法,无法从外部调用
- >>> test = Test()
- >>> test.__clac()
- Traceback (most recent call last):
- File "<pyshell#29>", line 1, in <module>
- test.__clac()
- AttributeError: 'Test' object has no attribute '__clac'
- >>> test.call()
- 成功调用内部方法
复制代码
self.stop和self.start都是本质上元组,那么self.stop[0:6]和self.start[0:6]也是元组
元组与元组相减会报错
- >>> import time
- >>> last = time.localtime()
- >>> now = time.localtime()
- >>> now[0:6] - last[0:6]
- Traceback (most recent call last):
- File "<pyshell#34>", line 1, in <module>
- now[0:6] - last[0:6]
- TypeError: unsupported operand type(s) for -: 'tuple' and 'tuple'
- >>>
复制代码
所以采用for循环将元素一个个提取出来计算~ |
|