|
发表于 2018-11-15 15:54:20
|
显示全部楼层
本楼为最佳答案
- from turtle import *
- text=input('请输入年月日:(20181111):')
- l=len(text)
- setup(800,800,0,800)
- pencolor('red')
- hideturtle()
- pensize(4)
- def draw(i,s):
- home()
- penup()
- goto(i*60-300,0)
- if s=='1':
- fd(40)
- rt(90)
- pendown()
- fd(80)
- if s=='2':
- pendown()
- fd(40)
- rt(90)
- fd(40)
- rt(90)
- fd(40)
- lt(90)
- fd(40)
- lt(90)
- fd(40)
- if s=='3':
- pendown()
- fd(40)
- rt(90)
- fd(80)
- rt(90)
- fd(40)
- penup()
- goto(i*60-300,-40)
- pendown()
- rt(180)
- fd(40)
- if s=='4':
- pendown()
- rt(90)
- fd(40)
- lt(90)
- fd(40)
- lt(90)
- fd(40)
- lt(180)
- fd(80)
- if s=='5':
- pendown()
- fd(40)
- goto(i*60-300,0)
- rt(90)
- fd(40)
- lt(90)
- fd(40)
- rt(90)
- fd(40)
- rt(90)
- fd(40)
- if s=='6':
- goto(i*60-260,0)
- pendown()
- rt(180)
- fd(40)
- lt(90)
- fd(80)
- lt(90)
- fd(40)
- lt(90)
- fd(40)
- lt(90)
- fd(40)
- if s=='7':
- pendown()
- fd(40)
- rt(90)
- fd(80)
- if s=='8':
- pendown()
- fd(40)
- rt(90)
- fd(80)
- rt(90)
- fd(40)
- rt(90)
- fd(80)
- goto(i*60-300,-40)
- rt(90)
- fd(40)
- if s=='9':
- goto(i*60-260,-40)
- pendown()
- rt(180)
- fd(40)
- rt(90)
- fd(40)
- rt(90)
- fd(40)
- rt(90)
- fd(80)
- if s=='0':
- pendown()
- fd(40)
- rt(90)
- fd(80)
- rt(90)
- fd(40)
- rt(90)
- fd(80)
- penup()
- for i in range(len(text)):
- draw(i,text[i])
- mainloop()
复制代码 |
|