PYTHON中7段数码管绘制import turtle, time
def drawGap():
讪笑的意思turtle.speed(0) # 设置画笔速度 “fastest”:0 "fast":10 "normal":6 "slow":3 "slowest":1
# turtle.Turtle().screen.delay(0) #画笔速度⽆延迟
turtle.penup()
turtle.fd(5)
def drawLine(draw): # 绘制单段数码管
drawGap()
turtle.speed(0)
# turtle.Turtle().screen.delay(0)
turtle.pendown() if draw el turtle.penup()
葡萄英语
turtle.fd(40)
drawGap()
turtle.right(90)
def drawDigit(digit): # 根据数字绘制七段数码管
穿布拉达的女王
drawLine(True) if digit in [2, 3, 4, 5, 6, 8, 9] el drawLine(Fal)
drawLine(True) if digit in [0, 1, 3, 4, 5, 6, 7, 8, 9] el drawLine(Fal)
lucky jason mrazdrawLine(True) if digit in [0, 2, 3, 5, 6, 8, 9] el drawLine(Fal)
drawLine(True) if digit in [0, 2, 6, 8] el drawLine(Fal)
turtle.left(90)
drawLine(True) if digit in [0, 4, 5, 6, 8, 9] el drawLine(Fal)
drawLine(True) if digit in [0, 2, 3, 5, 6, 7, 8, 9] el drawLine(Fal)
lf
drawLine(True) if digit in [0, 1, 2, 3, 4, 7, 8, 9] el drawLine(Fal)
turtle.left(180)
turtle.penup() # 为绘制后续数字确定位置
turtle.fd(20) # 为绘制后续数字确定位置
def drawDate(date):
turtle.pencolor("red")
for i in date:
if i == '+':
turtle.write("年", font=("Arial", 18, "normal"))
turtle.pencolor("green")
turtle.fd(40)
elif i == '-':
turtle.write("⽉", font=("Arial", 18, "normal"))
turtle.pencolor("blue")
turtle.fd(40)
中文歌曲英文翻唱elif i == '*':
ann kathrinturtle.write("⽇", font=("Arial", 18, "normal"))
hcuturtle.pencolor("red")
turtle.fd(70)
elif i == '$':
turtle.write("时", font=("Arial", 18, "normal"))
turtle.pencolor("green")
turtle.fd(40)
elif i == '&':
turtle.write("分", font=("Arial", 18, "normal"))
turtle.pencolor("blue")
turtle.fd(40)
elif i == '@':
turtle.write("秒", font=("Arial", 18, "normal"))
el:
drawDigit(eval(i))
def main(): # 主函数
turtle.tup(1600, 1000, 0, 0)
turtle.penup()
turtle.left(90)
turtle.fd(200)
turtle.right(90)
turtle.fd(-600)
有道在线翻译下载turtle.pensize(5)
drawDate(time.strftime("%Y+%m-%d*%H$%M&%S@", time.localtime()))
city hallturtle.hideturtle()
turtle.done()
main()