1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| from turtle import *; from datetime import * def drawLine(draw): penup(); fd(5) pendown() if draw else penup() fd(40) penup(); fd(5) right(90) def drawDigit(i): drawLine(True) if i in [2,3,4,5,6,8,9] else drawLine(False) drawLine(True) if i in [0,1,3,4,5,6,7,8,9] else drawLine(False) drawLine(True) if i in [0,2,3,5,6,8,9] else drawLine(False) drawLine(True) if i in [0,2,6,8] else drawLine(False) left(90) drawLine(True) if i in [0,4,5,6,8,9] else drawLine(False) drawLine(True) if i in [0,2,3,5,6,7,8,9] else drawLine(False) drawLine(True) if i in [0,1,2,3,4,7,8,9] else drawLine(False) left(180); penup(); fd(20) def drawDate(date): for i in date: if i == '-': write('年', font=("Arial", 18, "normal")); fd(40) elif i == '=': write('月', font=("Arial", 18, "normal")); fd(40) elif i == '+': write('日', font=("Arial", 18, "normal")) else: drawDigit(eval(i)) if __name__ == "__main__": setup(800, 350, 200, 200) penup(); fd(-300) pensize(5) drawDate(datetime.now().strftime('%Y-%m=%d+')) hideturtle(); done()
|
评论区
欢迎你留下宝贵的意见,昵称输入QQ号会显示QQ头像哦~