[Python] Seven nixie tube years, months, days

import turtle #painting library 
import time #time library
def drawGap(): #each digital tube distance, make it look like a digital tube
turtle.penup()
turtle.fd(5)
def drawLine(draw): #single digital tube
drawGap ()
turtle.pendown() if draw else turtle.penup() #If true, go down, if false, up
turtle.fd(40)
drawGap()
turtle.right(90)
def drawDigit(digit): #Draw a few paragraphs of digital tubes according to the current number
drawLine(True) if digit in [2,3,4,5,6,8,9] else drawLine(False) #Do digital tube planning for 123456... and other numbers
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)
turtle.left(90) #There is no need to turn right here, so add a left turn
drawLine(True) if digit in [4,5,6,8,9,0] else drawLine(False)
drawLine(True) if digit in [2,3,5,6,7,8,9,0] else drawLine(False)
drawLine(True) if digit in [1,2,3,4,7,8,9,0] else drawLine(False )
turtle.left(180) #Direction to the right
turtle.penup()
#Pen up turtle.fd(20)
#Move def drawDate(date): #Start drawing time
turtle.pencolor('red') #First put the brush directly dyed red
for i in date:   
if i == '-': #if it
is- turtle.write('year',font=('Arial',18,'normal')) #then draw the year
turtle.pencolor ('green')
turtle.fd(40)
elif i == '=': #if yes=
turtle.write('month',font=('Arial',18,'normal')) #Then draw the month
turtle.pencolor('blue')
turtle.fd(40)
elif i == '+': # If it is +
turtle.write('日',font=('Arial',18,'normal')) #then draw the sun
else:    
drawDigit(eval(i)) #otherwise draw the digital tube normally
def main():
turtle.setup(800,350,200,200) #Canvas size
turtle.penup()
turtle.fd(-300)
turtle.pensize(5)
drawDate(time.strftime('%Y-%m=%d+',time.gmtime()) ) #Use gmtime to get the current time, format it into -=+ format, and then put it in drawDate()
turtle.hideturtle()
turtle.done()
main()
is plagiarizing the whole process, it's too difficult!
study hard, improve every day!

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325044305&siteId=291194637