类就先这样吧,看在昨天写了词云的份上
from time import sleep
import os
class Peach(object):
def __init__(self, hour=0, minute=0, second=0):
self._hour=hour
self._minute=minute
self._second = second
def run(self):
"""走字"""
self._second += 1
if self._second == 60:
self._second = 0
self._minute += 1
if self._minute == 60:
self._minute = 0
self._hour += 1
if self._hour == 24:
self._hour = 0
def show(self):
"""显示时间"""
return '%02d:%02d:%02d' % \
(self._hour, self._minute, self._second)
def main():
clock = Peach(13, 14, 15)
while True:
print(clock.show())
sleep(0.5)
clock.run()
if __name__ == '__main__':
main()
'''
13:14:15
13:14:16
13:14:17
13:14:18
13:14:19
13:14:20
13:14:21
13:14:22
13:14:23
13:14:24
13:14:25
13:14:26
13:14:27
13:14:28
13:14:29
'''