[Python] 纯文本查看 复制代码
import turtle
import time
import random
def draw (a):#判断划线否
turtle.pencolor(random.randint(1,255),random.randint(1,255),random.randint(1,255))
if a:
turtle.pendown()
else:
turtle.penup()
turtle.forward(40)
turtle.right(90)
def drawdight(dight):#判断数字是否划线
try:
if dight==" ":
dight =-2
else:
dight =int(dight)
except:
dight=-1
if dight in [2,3,4,5,6,8,9]:
draw(True)
else :
draw(False)
if dight in [0,1,3,4,5,6,7,8,9]:
draw(True)
else :
draw(False)
if dight in [0,2,3,5,6,8,9,-1]:
draw(True)
else :
draw(False)
if dight in [0,2,6,8]:
draw(True)
else :
draw(False)
turtle.left(90)
if dight in [0,4,5,6,8,9]:
draw(True)
else :
draw(False)
if dight in [0,2,3,5,6,7,8,9]:
draw(True)
else:
draw(False)
if dight in [1,2,3,4,7,8,9,0]:
draw(True)
else :
draw(False)
turtle.left(180)
turtle.penup()
turtle.fd(20)
def data(a):
for i in a:
drawdight(i)
def main():
turtle.setup(1200,400,200,200) #画布大小
turtle.penup()
turtle.fd(-400)
turtle.pensize(10) #画笔宽度
turtle.speed(23) #笔速
turtle.colormode(255)
while True:
turtle.pencolor(random.randint(1,255),random.randint(1,255),random.randint(1,255)) #hoice('red', 'green', 'blue'))
turtle.hideturtle()
data(time.strftime("%m_%d %H_%M_%S",time.localtime()))
#data("1234567890")
turtle.clear()
#turtle.reset()
turtle.penup()
turtle.goto(000,0)
turtle.right(0)
turtle.fd(-400)
#turtle.showturtle()
turtle.done()
main()