采用turtle库画出当前年月日时分秒
import turtle
import time
def drawOneLine(flag):
turtle.color("purple")
if flag == True:
turtle.pendown()
turtle.fd(50)
turtle.right(90)
turtle.penup()
else:
turtle.penup()
turtle.fd(50)
turtle.right(90)
turtle.pendown()
def drawOneNum(number):
drawOneLine(True) if number in [2,3,4,5,6,8,9] else drawOneLine(False)
drawOneLine(True) if number in [0,1,3,4,5,6,7,8,9] else drawOneLine(False)
drawOneLine(True) if number in [0,2,3,5,6,8] else drawOneLine(False)
drawOneLine(True) if number in [0,2,6,8] else drawOneLine(False)
turtle.left(90)
drawOneLine(True) if number in [0,4,5,6,8,9] else drawOneLine(False)
drawOneLine(True) if number in [0,2,3,5,6,7,8,9] else drawOneLine(False)
drawOneLine(True) if number in [0,1,2,3,4,7,8,9] else drawOneLine(False)
def drawt(t):
for i in t:
print(eval(i))
drawOneNum(eval(i))
turtle.penup()
turtle.seth(0)
turtle.fd(10)
turtle.pendown()
def main():
turtle.setup(1000, 350, 200, 200)
turtle.penup()
turtle.pensize(5)
turtle.goto(-450,0)
turtle.pendown()
drawt(time.strftime('%Y%m%d%H%M%S',time.gmtime()))
turtle.hideturtle()
turtle.done()
main()
运行结果如下:
仅仅记录学习的历程,便于以后的翻阅