首页 > 其他分享 >7段数码管绘制

7段数码管绘制

时间:2023-11-20 23:57:13浏览次数:29  
标签:popline elif False True else 数码管 fd 绘制

要求:画出,系统时间。具体包括:小时,分,秒,星期。 

import turtle as t
import time
a = time.strftime('%a',time.localtime())
if a=='Mon':
    c = 1
elif a == 'Tue':
    c =2
elif a == 'Wed':
    c =3
elif a =='Thu':
    c =4
elif a == 'Fri':
    c =5
elif a == 'Sat':
    c =6
elif a == 'Sun':
    c == 7
def popspace(): #单管间隔
    t.penup()
    t.fd(4)
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("red")
    for i in date:
        if i == '*':
            t.write('时',font=("宋体", 30, "normal"))
            t.pencolor(("green"))
            t.fd(60)
        elif i == '/':
            t.write('分',font=("宋体", 30, "normal"))
            t.pencolor("orange")
            t.fd(60)
        elif i == '!':
            t.write('秒',font=("宋体", 30, "normal"))
            t.pencolor("pink")
            t.fd(60)
        elif i == '-':
            t.write('星期 ',font=("宋体", 30, "normal"))
            t.fd(60)
        else:
            popstart(eval(i))
def main():
    t.setup(900, 700, 200,200)
    t.penup()
    t.fd(-350)
    t.pensize(4)
    popdate(time.strftime('%H*%M/%S!-c',time.localtime()))
    t.hideturtle()
main()

运行结果

 

标签:popline,elif,False,True,else,数码管,fd,绘制
From: https://www.cnblogs.com/0cyy0/p/17845142.html

相关文章

  • 七段数码管显示时间
    importturtleimportdatetimeimporttimedefdraw_gap():#绘制数码间隔turtle.penup()turtle.fd(5)defdraw_line(draw):#绘制单段数码管draw_gap()turtle.pendown()ifdrawelseturtle.penup()turtle.fd(40)draw_gap()turt......
  • 数码管
    #数码管显示系统年,月,日,时间1importturtle,datetime2defdrawling(draw):34turtle.pendown()ifdrawelseturtle.penup()5turtle.fd(40)6turtle.right(90)78defdraworigin(d):9drawling(True)ifdin[2,3,4,5,6,8,9]elsedr......
  • 7段数码管绘制
    7段数管码代码运行22信计1班34号代码#e7.2DrawSevenSegDisplay.pyimportturtle,datetimedefdrawGap():#绘制数码管间隔turtle.penup()turtle.fd(5)defdrawLine(draw):#绘制单段数码管drawGap()turtle.pendown()ifdrawelseturtle.penup()turtle......
  • 七段数码管绘制
    importturtle,datetimedefdrawGap():#绘制数码管间隔turtle.penup()turtle.fd(5)defdrawLine(draw):#绘制单段数码管drawGap()turtle.pendown()ifdrawelseturtle.penup()turtle.fd(40)drawGap()turtle.right(90)defdrawDigit(d):#根据......
  • 7段数码管绘制
    importtimeimportturtleasttdefdrawGap():tt.penup()tt.fd(5)defdrawLine(draw):drawGap()if(draw):tt.pendown()else:tt.penup()tt.fd(50)drawGap()tt.right(90)defdrawDate(date):tt.pencolor("red"......
  • revit中绘制标高轴网
    1、轴网操作:添加标高需要在平面视图中添加,添加完成后可重命名,对齐等主要使用场景:主要用于测试模型审查的碰撞审查点的轴网取值,主要要模拟的场景在轴网内部和边界处--根据实际业务需求得出 2、标高操作:轴网需要在立面视图中添加,添加完成后可重命名、对齐等主要使用场景:主......
  • revit中绘制图纸
    目标:在revit中可自定义操作图纸,用于测试二维批注内容直接在图纸此处鼠标右键进行图纸的将新建及编辑,可自己拖动视口到图纸,也可以自己复制视口--该点主要用于测试一个二维批注被多个图纸的多个视口截取 备注:在revit中同一个模型图纸不允许重名,同一个视口不允许被拖动到多......
  • CAD中查看图元属性、绘制region、绘制block、绘制xc
    一、选中图元,编辑,查看属性 二、面域命令:region选定一个封闭图形,回车 三、块的新建及编辑命令:block选定一个封闭图形,命名,确定 四、XC前提:对块进行操作命令:xclip......
  • 七段数码管绘制
    七段数码管绘制#请学号最后一个尾号为(2,3)的同学。画出,系统时间。具体包括:年,月,日,小时,分。importturtle,datetimedefdrawGap():#绘制码管间距turtle.penup()turtle.fd(5)defdrawLine(draw):#绘制单段数码管drawGap()turtle.pendown()ifdrawelseturt......
  • 7段数码管绘制
    importturtle,datetimedefdrawGap():#绘制数码管间隔turtle.penup()turtle.fd(5)defdrawLine(draw):#绘制单段数码管drawGap()turtle.pendown()ifdrawelseturtle.penup()turtle.fd(40)drawGap()turtle.right(90)defdrawDigit(d):#......