鱼C论坛

 找回密码
 立即注册
查看: 835|回复: 1

我跟小甲鱼写的一样的为什么我打印出来的值是这样的

[复制链接]
发表于 2018-11-7 20:30:05 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
import time as t
class Mytimer():
    #开始计时
    def start(self):
        self.start = t.localtime()
        print('计时开始.....')

    #停止计时
    def stop(self):
        self.stop = t.localtime()
        self.__calc()
        print('计时结束!...')

    #内部方法,计算运行时间
    def __calc(self):
        self.lasted = []
        self.prompt = '总共运行了'
        for index in range(6):
            self.lasted.append(self.stop[index] - self.start[index])
            self.prompt += str(self.lasted[index] - self.start[index])
            print(self.prompt)



a = Mytimer()
>>> a.start()
计时开始.....
>>> a.stop()
总共运行了-2018
总共运行了-2018-11
总共运行了-2018-11-7
总共运行了-2018-11-7-20
总共运行了-2018-11-7-20-20
总共运行了-2018-11-7-20-20-18
计时结束!...
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2018-11-7 20:41:27 | 显示全部楼层
self.prompt += str(self.lasted[index] - self.start[index])改成
self.prompt += str(self.stop[index] - self.start[index])
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2026-1-3 15:13

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表