首页 > 其他分享 >数码管

数码管

时间:2023-11-20 22:13:27浏览次数:29  
标签:turtle False drawling 40 else 数码管 True

# 数码管

显示系统年,月,日,时间

 1 import turtle,datetime
 2 def drawling(draw):
 3 
 4     turtle.pendown() if draw else turtle.penup()
 5     turtle.fd(40)
 6     turtle.right(90)
 7 
 8 def draworigin(d):
 9     drawling (True) if d in [2,3,4,5,6,8,9] else drawling (False)
10     drawling (True) if d in [0,1,3,4,5,6,7,8,9,'A','b','d'] else drawling (False)
11     drawling (True) if d in [0,2,3,5,6,8,'b','b','E'] else drawling (False)
12     drawling (True) if d in [0,2,6,8,'A','b','C','d','E','F'] else drawling (False)
13 
14     turtle.left(90)
15     drawling (True) if d in [0,4,5,6,8,9,'A','b','C','E','F'] else drawling (False)
16     drawling (True) if d in [0,2,3,5,6,7,8,9,'A','C','E','F'] else drawling (False)
17     drawling (True) if d in [0,1,2,3,4,7,8,9,'A','d','E','F'] else drawling (False)
18     turtle.left(180)
19     turtle.penup()
20     turtle.fd(20)
21 def drawdate(date):
22     turtle.pencolor("aquamarine2")
23     for I in date:
24         if I == '-':
25             turtle.write("年", font=("Arial", 18, "normal"))
26             turtle.pencolor("pale green")
27             turtle.fd(40)
28         elif I == '=':
29             turtle.write("月", font=("Arial", 18, "normal"))
30             turtle.pencolor("spring green")
31             turtle.fd(40)
32         elif I == '+':
33             turtle.write("日", font=("Arial", 18, "normal"))
34             turtle.pencolor("green yellow")
35             turtle.fd(40)
36         elif I == '*':
37             turtle.write("时", font=("Arial", 18, "normal"))
38             turtle.pencolor("cyan")
39             turtle.fd(40)
40         else:
41             draworigin(eval(I))
42         
43     
44     
45 def main():
46     turtle.setup(1000,450,200,200)
47     turtle.penup()
48     turtle.pensize(7)
49     turtle.speed("fast")
50     turtle.fd(-400)
51     turtle.pendown()
52     drawdate(datetime.datetime.now().strftime("%Y-%m=%d+%H*"))
53 
54 main()
55 turtle.done()

 

运行结果

21:52:40

干员:XinJi[21][1][41]

42

 

标签:turtle,False,drawling,40,else,数码管,True
From: https://www.cnblogs.com/Calinio/p/17845016.html

相关文章

  • 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"......
  • 七段数码管绘制
    七段数码管绘制#请学号最后一个尾号为(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):#......
  • 七段数码管绘制
    importturtle,datetimedefdrawGap():#绘制数码管间隔turtle.penup()turtle.fd(5)defdrawLine(draw):#绘制单段数码管drawGap()turtle.pendown()ifdrawelseturtle.penup()turtle.fd(40)drawGap()turtle.right(90)defdrawDigit(d):#根据数字......
  • 点阵LED数码管显示驱动IC VK16K33 A/B/C/BA/AA 驱动电流大 质量稳定 适用于计量插座,数
    概述VK16K33是一种带按键扫描接口的数码管或点阵LED驱动控制专用芯片,内部集成有数据锁存器、键盘扫描、LED驱动模块等电路。数据通过I2C通讯接口与MCU通信。SEG脚接LED阳极,GRID脚接LED阴极,可支持16SEGx8GRID的点阵LED显示面板。最大支持13×3的按键。内置上电复位电路,整体闪烁频......
  • 07_数码管
    数码管就算有多个数码管被点亮也显示相同的数字数码管原理图译码器原理图高低位表示数码管LED3显示3#include<REGX52.H>voidmain(){ //高低位顺序:CBA P2_4=0;//C P2_3=1;//B P2_2=0;//A P0=0x4F;//显示3 while(1) { }}运行效果指定第......
  • 04-共阳数码管的动态显示
    共阳数码管的动态显示代码如下:#include<REGX52.H>voidDisplay_Dynamic();unsignedcharmonth=1;voidDelay_ms(unsignedintxms){ unsignedinti,j; for(i=0;i<xms;i++){ for(j=0;j<299;j++); }}voidDelay(unsignedchart){ while(t--){ //......
  • 03-共阳极数码管的静态显示
    共阳数码管的静态显示由电路图可知此为共阳数码管#include<REGX52.H>unsignedintcodenum[16]={ 0xc0, //011000000 0xf9,//111111001abged为0 0xa4,//210100100 0xb0,//3 0x99,//4 0x92,//5 0x......