今天我们来讲一讲时钟的代码
下面是IDLE的代码:
import turtle as t
import datetime as d
def skip(step): #抬笔,跳到一个地方
t.penup()
t.fd(step)
t.pendown()
def drawClock(radius): #画表盘
t.speed(0)
t.mode("logo") #以logo坐标、角度方式
t.hideturtle()
t.pensize(7)
t.home() #回到原点
for j in range(60): #0~59
skip(radius)
if (j%5==0): #%是取余==等于号
t.forward(20)
skip(-radius-20)
else:
t.dot(5)
skip(-radius)
t.right(6)
drawClock(150) #调用表盘程序
def makePoint(pointName,len): #钟的指针,时针、分针、秒针
t.penup()
t.home()
t.begin_poly()
t.back(0.1*len)
t.fd(len*1.1)
t.end_poly()
poly=t.get_poly()
t.register_