【实例简介】
【实例截图】
【核心代码】
import turtle as t
import time
def drawgap():
t.pu()
t.fd(5)
def drawline(draw):
drawgap()
t.pd() if draw else t.pu()
t.fd(40)
drawgap()
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(True) if digit in [0,1,2,3,4,7,8,9] else drawline(False)
t.right(180)
t.pu()
t.fd(40)
def drawdate(date):
for i in date:
if i =='-':
t.write('年',font=("Arial",18,"normal"))
t.pencolor("red")
t.fd(80)
elif i=="=":
t.write('月',font=("Arial",18,"normal"))
t.pencolor("blue")
t.fd(80)
elif i==" ":
t.write("日",font=("Arial",18,"normal"))
else:
drawdigit(eval(i))
def main():
t.setup(1000,350,200,200)
t.speed(0)
t.pu()
t.fd(-450)
t.pensize(5)
t.pencolor("pink")
drawdate(time.strftime('%H-%M=%S ',time.gmtime()))
t.hideturtle()
t.done()
main()