Recently, I've been working on a tool that asks for the time it takes to run the program, so I made a timer.
Found on the internet a lot of discoveries are 24-hour system, more than 24 hours will be back 0
And then, based on the 24-hour system, I modified a constant-time
If you want to display more than 24 hours in the day, you can modify the accumulated part of the Code
#-*-coding:utf-8-*-ImportSYS fromPyqt5.qtwidgetsImport* fromPyqt5.qtcoreImport* fromPyqt5.qtcoreImportQtimer, QtimeclassFirstwindow (qwidget): Close_signal=pyqtsignal ()def __init__(Self, parent=None): Super (Firstwindow, self).__init__(parent) self.resize (100, 100) Self.timer= Qtimer ()#Self.timeclock =qtime () self.h24=0 Self.istimestart=False Self.label=Qlabel (self) self.label.setText ('0:00:00') if notSelf.isTimeStart:self.timeClock.setHMS (0, 0, 0) self.timer.start (1000)#start timer, the timer object emits a timeout signal every secondSelf.istimestart =True self.timer.timeout.connect (self.addtime)defAddtime (self):#chronograph time is increased by one second and displayed on QlableSelf.timeclock = self.timeClock.addMSecs (1000)#time increases by one secondTime = self.timeClock.toString ("Hh:mm:ss") ifTime = ="00:00:00": Self.h24+ = 24h= Int (Time.split (":") [0]) +self.h24 M= Time.split (":") [1] s= Time.split (":") [2] New_time="%d:%s:%s"%(H, M, s) self.label.setText (new_time)#Label Display Timeif __name__=="__main__": App=qapplication (SYS.ARGV) ex=Firstwindow () ex.show () Sys.exit (App.exec_ ())
Python time accumulates more than 24 hours and continues to accumulate