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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
| ''' Created on Dec 5, 2017
@author: QiZhao ''' import turtle,datetime
def drawGap(): turtle.penup() turtle.fd(5) def drawline(flag): drawGap() turtle.pendown() if(flag==False): turtle.penup() turtle.fd(40) drawGap() turtle.right(90) def drawdight(dight): if dight in [2,3,4,5,6,8,9]: drawline(True) else: drawline(False) if dight in [0,1,3,4,5,6,7,8,9]: drawline(True) else: drawline(False) if dight in [0,2,3,5,6,8]: drawline(True) else: drawline(False) if dight in [0,2,6,8]: drawline(True) else: drawline(False) turtle.left(90) if dight in [0,4,5,6,8,9]: drawline(True) else: drawline(False) if dight in [0,2,3,5,6,7,8,9]: drawline(True) else: drawline(False) if dight in [0,1,2,3,4,7,8,9]: drawline(True) else: drawline(False) turtle.setheading(0) turtle.fd(25)
def drawdata(data): turtle.color("red") for i in data: if i=='+': turtle.write('年',font=("宋体", 24, "normal")) turtle.color("green") turtle.fd(30) elif i=='-': turtle.write('月',font=("宋体", 24, "normal")) turtle.color("blue") turtle.fd(30) elif i=='*': turtle.write('日',font=("宋体", 24, "normal")) else: drawdight(eval(i)) def main(): turtle.setup(800,500) turtle.penup() turtle.fd(-350) turtle.pendown() turtle.hideturtle() turtle.pensize(6) turtle.speed(9) drawdata(datetime.datetime.now().strftime('%Y+%m-%d*')) a=input() main()
|