祝福2020平安无事happy一年
#e7.1DrawSevenSepDisplay.py
import turtle
def drawline(draw):
#绘制单段数码管
turtle.pendown() if draw else turtle.penup()
#如果draw is True ,则落笔,否则抬笔
turtle.fd(40)
turtle.right(90)
def drawDigit(d):
#根据数字绘制七段数码管
drawline(True) if d in ['2','3','4','5','6','8','9','h','a','p','y'] else drawline(False)
#位于中心的一横
drawline(True) if d in ['0','1','3','4','5','6','7','8','9','h','a'] else drawline(False)
#第二笔
drawline(True) if d in ['0','2','3','5','6','8','9'] else drawline(False)
#第三笔
drawline(True) if d in ['0','2','6','8','h','a','p','y'] else drawline(False)
#第四笔
turtle.left(90)
#左转90度,向上
drawline(True) if d in ['0','4','5','6','8','9','h','a','p','y'] else drawline(False)
#第五笔
drawline(True) if d in ['0','2','3','5','6','7','8','9','a','p'] else drawline(False)
#第六笔
drawline(True) if d in ['0','1','2','3','4','7','8','9','h','a','p','y'] else drawline(False)
#第七笔
turtle.left(180)
turtle.penup()
turtle.fd(20)
def drawDate(date):
for i in date:
drawDigit(i)
#输入日期,逐一绘制数字
def main():
turtle.setup(800,350,200,200)
turtle.penup()
turtle.fd(-300)
turtle.pensize(5)
turtle.pencolor('purple')
drawDate('2020 happy')
turtle.hideturtle()
turtle.done()
main()