# -*- coding: utf-8 -*-
import turtle
import time
def draw_clock(r): # 画钟表的函数
turtle.pensize(5)
turtle.penup()
turtle.goto(0, -r)
turtle.pendown()
turtle.circle(r)
turtle.penup()
turtle.goto(0,0)
turtle.pendown()
for i in range(12):
turtle.penup()
turtle.goto(0, r-20)
turtle.right(i*30)
turtle.forward(r-20)
turtle.write(i+1)
def draw_hand(handname, length):
# 画指针的函数
turtle.pensize(4)
turtle.pencolor('black')
turtle.pencolor()
turtle.penup()
turtle.goto(0,0)
turtle.down()
turtle.seth(180)
turtle.rt(handname*30)
turtle.fd(length)
def get_time():
# 获取当前时间的函数
t = time.localtime()
hour = t.tm_hour
minute = t.tm_min
second = t.tm_sec
return hour, minute, second
def clock():
# 主函数,控制钟表的运转
turtle.speed(0)
draw_clock(200)
while True:
hour, minute, second = get_time()
draw_hand(hour, 60)
draw_hand(minute, 100)
draw_hand(second, 150)
turtle.goto(0, -220)
turtle.write(str(hour)+":"+str(minute)+":"+str(second), align="center",
font=("Arial", 20, "normal"))
turtle.clear()
if __name__ == '__main__':
clock()
用Python编写的维吾尔语时间表代码
文件列表
时间表.zip
(预估有个1文件)
时间表.py
4KB
暂无评论