7段数码管绘制

#七段数码管绘制
import turtle as t
import time
def popspace(): 
    t.penup()  
    t.fd(5)  
def popline(draw):  
    popspace()  
    t.pendown() if draw else t.penup()  
    t.fd(40)  
    popspace()  
    t.right(90)  
def popstart(d):  
    popline(True) if d in [2,3,4,5,6,8,9] else popline(False)  
    popline(True) if d in [0,1,3,4,5,6,7,8,9] else popline(False)  
    popline(True) if d in [0,2,3,5,6,8,9] else popline(False)  
    popline(True) if d in [0,2,6,8] else popline(False)  
    t.left(90)  
    popline(True) if d in [0,4,5,6,8,9] else popline(False)  
    popline(True) if d in [0,2,3,5,6,7,8,9] else popline(False)  
    popline(True) if d in [0,1,2,3,4,7,8,9] else popline(False)  
    t.left(180)  
    t.penup()  
    t.fd(30)  
def popdate(date):  
    t.pencolor((1,0.36,0.28))
    t.speed(9)  
    for i in date:  
        if i == '-':  
            t.write('年',font=("Arial", 30, "normal"))  
            t.pencolor((0.93,0.51,0.93))  
            t.fd(60)  
        elif i == '=':  
            t.write('月',font=("Arial", 30, "normal"))  
            t.pencolor((0.5,0.5,0))  
            t.fd(60)  
        elif i == '+':  
            t.write('日',font=("Arial", 30, "normal"))
            t.pencolor((0.25,0.88,0.82))
            t.fd(40)
            t.seth(-90)
            t.fd(100)
            t.seth(180)
            t.fd(700)
            t.seth(-90)
            t.fd(40)
            t.seth(0)
            t.fd(40)
        elif i == '*':
            t.write('时',font=("Arial", 30, "normal"))
            t.pencolor((0.18,0.55,0.34))
            t.fd(60)
        elif i == '/':  
            t.write('分',font=("Arial", 30, "normal"))
            t.pencolor((1,0.89,0.77))
            t.fd(60)
        elif i == '!':  
            t.write('秒',font=("Arial", 30, "normal")) 
        else:  
            popstart(eval(i))  
def main():
    t.setup(1000, 800, None,None)  
    t.penup()  
    t.fd(-350)  
    t.pensize(6)  
    popdate(time.strftime('%Y-%m=%d+%H*%M/%S!',time.localtime()))  
    t.hideturtle()  
main()

7段数码管绘制
画出,系统时间
具体包括:年,月,日,小时,分,秒
以上不同的部分要用不同的颜色区别开来
以上部分,要注明是年月日,例如:2020年,这个年字必须显示出来。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值