本实例原本是Mooc课程上的一个案例,稍加修改后可以显示实时时间
Python代码:
# -*- coding: utf-8 -*-
# @Author: Marte
# @Date: 2020-07-22 18:34:56
# @Last Modified by: Marte
# @Last Modified time: 2020-07-23 13:52:15
# @Description: 七段数码管
import turtle as t
import time
def DrawLine(draw):
t.pendown() if draw else t.penup()
t.fd(30)
t.right(90)
def DrawDigit(digit):
DrawLine(True) if digit in [2,3,4,5,6,8,9] else DrawLine(False)
DrawLine(True) if digit in [0,1,3,4,5,6,7,8,9] else DrawLine(False)
DrawLine(True) if digit in [0,2,3,5,6,8,9] else DrawLine(False)
DrawLine(True) if digit in [0,2,6,8] else DrawLine(False)
t.left(90)
DrawLine(True) if digit in [0,4,5,6,8,9] else DrawLine(False)
DrawLine(True) if digit in [0,2,3,5,6,7,8,9] else DrawLine(False)
DrawLine(